Skip to content

Instantly share code, notes, and snippets.

@rusilko
Created March 25, 2016 18:27
Show Gist options
  • Save rusilko/48899b4808eba9804d37 to your computer and use it in GitHub Desktop.
Save rusilko/48899b4808eba9804d37 to your computer and use it in GitHub Desktop.
class DataWrapper
def initialize(data_hash)
raise ArgumentError unless data_hash.is_a? Hash
@data_hash = data_hash
end
def add(name, value)
DataWrapper.new(data_hash.merge({ name.to_sym => value }))
end
def to_hash
data_hash
end
private; attr_reader :data_hash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment