Module: CouchRest::Mixins::Properties::ClassMethods

Defined in:
lib/couchrest/mixins/properties.rb

Instance Method Summary collapse

Instance Method Details

#property(name, *options, &block) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/couchrest/mixins/properties.rb', line 49

def property(name, *options, &block)
  opts = { }
  type = options.shift
  if type.class != Hash
    opts[:type] = type
    opts.merge!(options.shift || {})
  else
    opts.update(type)
  end
  existing_property = self.properties.find{|p| p.name == name.to_s}
  if existing_property.nil? || (existing_property.default != opts[:default])
    define_property(name, opts, &block)
  end
end