Skip to content

Instantly share code, notes, and snippets.

@kangkyu
Last active October 1, 2015 05:02
Show Gist options
  • Save kangkyu/67b8ed03fbaa67d87659 to your computer and use it in GitHub Desktop.
Save kangkyu/67b8ed03fbaa67d87659 to your computer and use it in GitHub Desktop.
class Sample
def initialize(hsh)
@hsh = hsh
end
def method_missing(method)
key = @hsh.has_key?(method) ? method : method.to_s
@hsh[key]
end
end
h = {"this" => [1,2,3,4,5,6], "that" => ['here', 'there', 'everywhere'], :other => 'here'}
c = Sample.new(h)
p c.this
p c.that
p c.other
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment