Sha256: 8900ebf00842650a50b52d75266aecf3163f36db315d02c5a44390f121ffa02e
Contents?: true
Size: 573 Bytes
Versions: 2
Compression:
Stored size: 573 Bytes
Contents
# A module which adds some generators for hash based accessors. module HashAttrs def hash_reader(hash, syms) syms.each do |id| class_eval <<-"stop" def #{id.to_s.downcase} return @#{hash.to_s}[:#{id.to_s.downcase}] end stop end end def hash_writer(hash, syms) syms.each do |id| class_eval <<-"stop" def #{id.to_s.downcase}=(val) return @#{hash.to_s}[:#{id.to_s.downcase}] = val end stop end end def hash_accessor(hash, syms) hash_reader(hash, syms) hash_writer(hash, syms) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
icalendar-0.96.1 | lib/hash_attrs.rb |
icalendar-0.96.2 | lib/hash_attrs.rb |