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