Module: SmoothOperator::AttributeAssignment
- Included in:
- OpenStruct
- Defined in:
- lib/smooth_operator/attribute_assignment.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#_meta_data ⇒ Object
readonly
Returns the value of attribute _meta_data.
-
#_options ⇒ Object
readonly
Returns the value of attribute _options.
Instance Method Summary collapse
- #assign_attributes(attributes = {}, options = {}) ⇒ Object
- #initialize(attributes = {}, options = {}) ⇒ Object
Instance Attribute Details
#_meta_data ⇒ Object (readonly)
Returns the value of attribute _meta_data.
14 15 16 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 14 def @_meta_data end |
#_options ⇒ Object (readonly)
Returns the value of attribute _options.
14 15 16 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 14 def @_options end |
Instance Method Details
#assign_attributes(attributes = {}, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 16 def assign_attributes(attributes = {}, = {}) attributes = _extract_attributes(attributes) return nil unless attributes.is_a?(Hash) induce_errors(attributes.delete(self.class.errors_key)) @_options.merge!() if .is_a? Hash attributes.each do |name, value| next unless allowed_attribute(name) send("#{name}=", value) end end |
#initialize(attributes = {}, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 4 def initialize(attributes = {}, = {}) @_options = {} before_initialize(attributes, ) assign_attributes(attributes, ) after_initialize(attributes, ) end |