Module HashAttrs
In: lib/hash_attrs.rb

A module which adds some generators for hash based accessors.

Methods

Public Instance methods

[Source]

    # 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

[Source]

   # 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

[Source]

    # File lib/hash_attrs.rb, line 15
15:   def hash_writer(hash, syms)
16:     syms.each do |id|
17:       class_eval "def \#{id.to_s.downcase}=(val)\nreturn @\#{hash.to_s}[:\#{id.to_s.downcase}] = val\nend\n"
18:     end
19:   end

[Validate]