Sha256: 61e7c617e3c21bee1d58496a90084820dd66ec57c1045258f82923435359d6f2
Contents?: true
Size: 815 Bytes
Versions: 1
Compression:
Stored size: 815 Bytes
Contents
module AttrMethods def attr_array(*names) names.each do |n| self.send :define_method, n do |*value| if value.nil? || value.empty? return instance_variable_get "@#{n}" else instance_variable_set "@#{n}", value end end self.send :define_method, "#{n}=" do |value| instance_variable_set "@#{n}", value end end end def attr_hash(*names) names.each do |n| self.send :define_method, n do |*value| if value.nil? || value.empty? instance_variable_get "@#{n}" else instance_variable_set "@#{n}", value[0] end end self.send :define_method, "#{n}=" do |value| instance_variable_set "@#{n}", value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
albacore-0.1.5 | lib/albacore/support/attrmethods.rb |