Class: SmoothOperator::ArrayWithMetaData
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SmoothOperator::ArrayWithMetaData
- Defined in:
- lib/smooth_operator/array_with_meta_data.rb
Instance Attribute Summary collapse
-
#internal_array ⇒ Object
readonly
Returns the value of attribute internal_array.
-
#meta_data ⇒ Object
readonly
Returns the value of attribute meta_data.
Instance Method Summary collapse
-
#initialize(attributes, object_class) ⇒ ArrayWithMetaData
constructor
A new instance of ArrayWithMetaData.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(attributes, object_class) ⇒ ArrayWithMetaData
Returns a new instance of ArrayWithMetaData.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/smooth_operator/array_with_meta_data.rb', line 6 def initialize(attributes, object_class) _attributes, _resources_name = attributes.dup, object_class.resources_name @internal_array = [*_attributes[_resources_name]].map { |array_entry| object_class.new(array_entry).tap { |object| object.reloaded = true } } _attributes.delete(_resources_name) = _attributes super(@internal_array) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
17 18 19 20 |
# File 'lib/smooth_operator/array_with_meta_data.rb', line 17 def method_missing(method, *args, &block) _method = method.to_s .include?(_method) ? [_method] : super end |
Instance Attribute Details
#internal_array ⇒ Object (readonly)
Returns the value of attribute internal_array.
4 5 6 |
# File 'lib/smooth_operator/array_with_meta_data.rb', line 4 def internal_array @internal_array end |
#meta_data ⇒ Object (readonly)
Returns the value of attribute meta_data.
4 5 6 |
# File 'lib/smooth_operator/array_with_meta_data.rb', line 4 def end |