Module: SimplyCouch::Model::Persistence::Properties::ClassMethods
- Defined in:
- lib/simply_couch/model/persistence.rb
Instance Method Summary collapse
- #check_existing_properties(name, type) ⇒ Object
- #property(name, options = {}) ⇒ Object
- #property_names ⇒ Object
Instance Method Details
#check_existing_properties(name, type) ⇒ Object
126 127 128 129 130 |
# File 'lib/simply_couch/model/persistence.rb', line 126 def check_existing_properties(name, type) existing = properties.find{|p| name.to_sym == p.name.to_sym} return if existing.nil? || existing.class == type raise "Property #{name} already defined as #{existing.class}, cannot redefine as #{type}" end |
#property(name, options = {}) ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/simply_couch/model/persistence.rb', line 118 def property(name, = {}) am = send(:generated_attribute_methods) am.module_eval { undef_method(name) if instance_methods.include?(name) } define_attribute_method name properties << SimpleProperty.new(self, name, ) am.send(:remove_method, name) if am.instance_methods.include?(name) end |
#property_names ⇒ Object
116 |
# File 'lib/simply_couch/model/persistence.rb', line 116 def property_names; properties.map(&:name); end |