Class: SmoothOperator::Relation::ArrayRelation
- Inherits:
-
Object
- Object
- SmoothOperator::Relation::ArrayRelation
- Defined in:
- lib/smooth_operator/relation/array_relation.rb
Instance Attribute Summary collapse
-
#association ⇒ Object
readonly
Returns the value of attribute association.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(object, association) ⇒ ArrayRelation
constructor
A new instance of ArrayRelation.
- #method_missing(method, *args, &block) ⇒ Object
- #new(attributes = {}) ⇒ Object (also: #build)
- #reload ⇒ Object
Constructor Details
#initialize(object, association) ⇒ ArrayRelation
Returns a new instance of ArrayRelation.
7 8 9 |
# File 'lib/smooth_operator/relation/array_relation.rb', line 7 def initialize(object, association) @object, @association = object, association end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
11 12 13 |
# File 'lib/smooth_operator/relation/array_relation.rb', line 11 def method_missing(method, *args, &block) data.respond_to?(method) ? data.send(method, *args) : super end |
Instance Attribute Details
#association ⇒ Object (readonly)
Returns the value of attribute association.
5 6 7 |
# File 'lib/smooth_operator/relation/array_relation.rb', line 5 def association @association end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
5 6 7 |
# File 'lib/smooth_operator/relation/array_relation.rb', line 5 def object @object end |
Instance Method Details
#data ⇒ Object
15 16 17 18 19 |
# File 'lib/smooth_operator/relation/array_relation.rb', line 15 def data data = object.get_internal_data(association.to_s) data.nil? ? [] : [*data] end |
#new(attributes = {}) ⇒ Object Also known as: build
25 26 27 |
# File 'lib/smooth_operator/relation/array_relation.rb', line 25 def new(attributes = {}) object.class.reflect_on_association(association).klass.new(attributes) end |
#reload ⇒ Object
21 22 23 |
# File 'lib/smooth_operator/relation/array_relation.rb', line 21 def reload "TODO" end |