Module: Ripple::AttributeMethods::InstanceMethods
- Defined in:
- ripple/lib/ripple/attribute_methods.rb
Instance Method Summary (collapse)
-
- (Hash) attributes
A copy of the values of all attributes in the Document.
-
- (Object) attributes=(attrs, guard_protected_attrs = true)
Mass assign the document’s attributes.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block)
91 92 93 94 |
# File 'ripple/lib/ripple/attribute_methods.rb', line 91 def method_missing(method, *args, &block) self.class.define_attribute_methods super end |
Instance Method Details
- (Hash) attributes
A copy of the values of all attributes in the Document. The result is not memoized, so use sparingly. This does not include associated objects, nor embedded documents.
61 62 63 64 65 66 |
# File 'ripple/lib/ripple/attribute_methods.rb', line 61 def attributes self.class.properties.values.inject(@attributes.with_indifferent_access) do |hash, prop| hash[prop.key] = attribute(prop.key) hash end end |
- (Object) attributes=(attrs, guard_protected_attrs = true)
Mass assign the document’s attributes.
70 71 72 73 74 75 76 77 78 79 80 |
# File 'ripple/lib/ripple/attribute_methods.rb', line 70 def attributes=(attrs, guard_protected_attrs = true) raise ArgumentError, t('attribute_hash') unless Hash === attrs (guard_protected_attrs ? sanitize_for_mass_assignment(attrs) : attrs).each do |k,v| next if k.to_sym == :key if respond_to?("#{k}=") __send__("#{k}=",v) else __send__(:attribute=,k,v) end end end |