Class: StrapiModel::Relation
- Inherits:
-
Object
- Object
- StrapiModel::Relation
- Includes:
- Enumerable
- Defined in:
- lib/strapi_model/relation.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(klass, entries = []) ⇒ Relation
constructor
A new instance of Relation.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(klass, entries = []) ⇒ Relation
Returns a new instance of Relation.
7 8 9 10 |
# File 'lib/strapi_model/relation.rb', line 7 def initialize(klass, entries = []) @klass = klass @entries = entries end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/strapi_model/relation.rb', line 18 def method_missing(method, *args) if entries.respond_to?(method) entries.send(method, *args) else super end end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
5 6 7 |
# File 'lib/strapi_model/relation.rb', line 5 def entries @entries end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/strapi_model/relation.rb', line 5 def klass @klass end |
Instance Method Details
#each ⇒ Object
12 13 14 15 16 |
# File 'lib/strapi_model/relation.rb', line 12 def each entries.each do |item| yield item end end |