Module | HashAttrs |
In: |
lib/hash_attrs.rb
|
A module which adds some generators for hash based accessors.
# File lib/hash_attrs.rb, line 26 26: def hash_accessor(hash, syms) 27: hash_reader(hash, syms) 28: hash_writer(hash, syms) 29: end
# File lib/hash_attrs.rb, line 4 4: def hash_reader(hash, syms) 5: syms.each do |id| 6: class_eval "def \#{id.to_s.downcase}\nreturn @\#{hash.to_s}[:\#{id.to_s.downcase}]\nend\n" 7: end 8: end