Class: ElasticWeb::RelationCollection
- Includes:
- Enumerable
- Defined in:
- lib/elasticweb/relation_collection.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from Relation
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(data, options = {}) ⇒ RelationCollection
constructor
A new instance of RelationCollection.
Methods inherited from Relation
Constructor Details
#initialize(data, options = {}) ⇒ RelationCollection
Returns a new instance of RelationCollection.
7 8 9 10 11 12 13 14 15 |
# File 'lib/elasticweb/relation_collection.rb', line 7 def initialize(data, = {}) data = [] unless data.is_a?(Array) @collection = Array(data).map do |item| Relation.new(item) end @options = .with_indifferent_access end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ElasticWeb::Relation
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
5 6 7 |
# File 'lib/elasticweb/relation_collection.rb', line 5 def collection @collection end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/elasticweb/relation_collection.rb', line 5 def @options end |
Instance Method Details
#each ⇒ Object
17 18 19 20 21 |
# File 'lib/elasticweb/relation_collection.rb', line 17 def each return enum_for(:each) unless block_given? @collection.each { |item| yield item } end |