Module: CouchbaseOrm::AttributesDynamic
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/couchbase-orm/attributes/dynamic.rb
Instance Method Summary collapse
-
#respond_to?(name, include_private = false) ⇒ true | false
Override respond_to? so it responds properly for dynamic attributes.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used for allowing accessor methods for dynamic attributes.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/couchbase-orm/attributes/dynamic.rb', line 116 def method_missing(name, *args) attr = name.to_s return super unless attr.reader != 'id' && attributes.key?(attr.reader) getter = attr.reader if attr.writer? define_dynamic_writer(getter) @attributes.write_from_user(getter, args.first) args.first else define_dynamic_reader(getter) @attributes[getter].value end end |
Instance Method Details
#respond_to?(name, include_private = false) ⇒ true | false
Override respond_to? so it responds properly for dynamic attributes.
17 18 19 |
# File 'lib/couchbase-orm/attributes/dynamic.rb', line 17 def respond_to?(name, include_private = false) super || attributes&.key?(name.to_s.reader) end |