Sha256: 3dcc758ed3222bb62440256da7316424e5da0a66d4b7637447c7fccea296cab5
Contents?: true
Size: 623 Bytes
Versions: 3
Compression:
Stored size: 623 Bytes
Contents
module CouchPillow module Attributive # Declares a new Attribute # def attribute attr attr = attr.to_s.to_sym new_attr = Attribute.new(attr) attributes[attr] = new_attr # Define accessor methods define_method(attr) do @data[attr] end define_method("#{attr}=") do |val| @data[attr] = val end new_attr end def attributes @attributes ||= {} end def inherited(subclass) # Copy existing attributes to subclasses attributes.each do |k, v| subclass.attributes[k] = v end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
couchpillow-0.4.2 | lib/couchpillow/attributive.rb |
couchpillow-0.4.1 | lib/couchpillow/attributive.rb |
couchpillow-0.4.0 | lib/couchpillow/attributive.rb |