Module: SmoothOperator::AttributeAssignment
- Included in:
- OpenStruct::Base
- 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.
Class Method Summary collapse
Instance Method Summary collapse
- #assign_attributes(_attributes = {}, options = {}) ⇒ Object
- #has_data_from_server ⇒ Object (also: #from_server)
- #initialize(attributes = {}, options = {}) ⇒ Object
- #parent_object ⇒ Object
Instance Attribute Details
#_meta_data ⇒ Object (readonly)
Returns the value of attribute _meta_data.
56 57 58 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 56 def @_meta_data end |
#_options ⇒ Object (readonly)
Returns the value of attribute _options.
56 57 58 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 56 def @_options end |
Class Method Details
.included(base) ⇒ Object
8 9 10 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 8 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#assign_attributes(_attributes = {}, options = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 59 def assign_attributes(_attributes = {}, = {}) return nil unless _attributes.is_a?(Hash) attributes = _attributes = Helpers.stringify_keys(_attributes) if _attributes.include?(self.class.resource_name) attributes = _attributes.delete(self.class.resource_name) @_meta_data = _attributes end .each { |key, value| @_options[key] = value } if .is_a?(Hash) attributes.each { |name, value| push_to_internal_data(name, value) } end |
#has_data_from_server ⇒ Object Also known as: from_server
78 79 80 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 78 def has_data_from_server [:from_server] == true end |
#initialize(attributes = {}, options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 46 def initialize(attributes = {}, = {}) @_options = {} before_initialize(attributes, ) assign_attributes attributes, after_initialize(attributes, ) end |
#parent_object ⇒ Object
74 75 76 |
# File 'lib/smooth_operator/attribute_assignment.rb', line 74 def parent_object [:parent_object] end |