Module: CouchModel::Base::Accessor::ClassMethods
- Defined in:
- lib/couch_model/base/accessor.rb
Instance Attribute Summary collapse
-
#key_definitions ⇒ Object
readonly
Returns the value of attribute key_definitions.
Instance Method Summary collapse
- #key_accessor(*arguments) ⇒ Object
- #key_reader(key, options = { }) ⇒ Object
- #key_writer(key, options = { }) ⇒ Object
Instance Attribute Details
#key_definitions ⇒ Object (readonly)
Returns the value of attribute key_definitions.
18 19 20 |
# File 'lib/couch_model/base/accessor.rb', line 18 def key_definitions @key_definitions end |
Instance Method Details
#key_accessor(*arguments) ⇒ Object
38 39 40 41 |
# File 'lib/couch_model/base/accessor.rb', line 38 def key_accessor(*arguments) key_reader *arguments key_writer *arguments end |
#key_reader(key, options = { }) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/couch_model/base/accessor.rb', line 20 def key_reader(key, = { }) raise ArgumentError, "method #{key} is already defined" if method_defined?(:"#{key}") set_key_definition key, type = [:type] || :string send :"define_#{type}_reader", key rescue NoMethodError raise ArgumentError, "type #{type} isn't supported" end |
#key_writer(key, options = { }) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/couch_model/base/accessor.rb', line 29 def key_writer(key, = { }) raise ArgumentError, "method #{key}= is already defined" if method_defined?(:"#{key}=") set_key_definition key, type = [:type] || :string send :"define_#{type}_writer", key rescue NoMethodError raise ArgumentError, "type #{type} isn't supported" end |