Class: LHS::Collection::InternalCollection::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/lhs/concerns/collection/internal_collection.rb

Overview

The internal collection class that includes enumerable and insures to return LHS::Items in case of iterating items

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw, parent, record) ⇒ Collection

Returns a new instance of Collection.


19
20
21
22
23
# File 'lib/lhs/concerns/collection/internal_collection.rb', line 19

def initialize(raw, parent, record)
  self.raw = raw
  @parent = parent
  @record = record
end

Instance Attribute Details

#rawObject

Returns the value of attribute raw


15
16
17
# File 'lib/lhs/concerns/collection/internal_collection.rb', line 15

def raw
  @raw
end

Instance Method Details

#each(&_block) ⇒ Object


29
30
31
32
33
34
35
36
37
# File 'lib/lhs/concerns/collection/internal_collection.rb', line 29

def each(&_block)
  raw.each do |item|
    if item.is_a? Hash
      yield cast_item(item)
    else
      yield item
    end
  end
end

#to_aryObject


25
26
27
# File 'lib/lhs/concerns/collection/internal_collection.rb', line 25

def to_ary
  map { |item| item }
end