Sha256: 4158c505ad19d114643927192b5d8593007c1f21f21488688cc170585b02ba75

Contents?: true

Size: 545 Bytes

Versions: 3

Compression:

Stored size: 545 Bytes

Contents

module HorizonClient
  class Collection
    include Enumerable

    attr_reader :node

    def initialize(node)
      @node = node
      @rows = @node.locate(row_element_name).map do |row|
        Entity.new(row)
      end
    end

    def build
      row = Ox::Element.new(row_element_name)
      node << row
      entity = Entity.new(row)
      @rows.push(entity)
      entity
    end

    def rows
      @rows
    end

    def each(&block)
      @rows.each(&block)
    end

    private

    def row_element_name
      'row'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
horizon_client-0.2.7 lib/horizon_client/collection.rb
horizon_client-0.2.6 lib/horizon_client/collection.rb
horizon_client-0.2.5 lib/horizon_client/collection.rb