Sha256: 9b86e6f81eeb0feb148378a72e82909aa302f8b69428869d1c1f86d1927c3aba

Contents?: true

Size: 577 Bytes

Versions: 5

Compression:

Stored size: 577 Bytes

Contents

module Roqua
  module CoreApi
    # @api private
    class Dossiers < ActiveInteraction::Base
      model :session, class: Sessions::OAuthSession

      # usage:
      # Roqua.CoreApi.Dossiers.run!.each do |d|
      #   puts d.id, d.birth_year, d.gender
      # end
      def execute
        response = session.get "/dossiers"
        create_enum(response['headers'], response['rows'])
      end

      def create_enum(headers, rows)
        row_class = Struct.new(*headers.map(&:to_sym))
        rows.lazy.map { |row| row_class.new(*row) }.to_enum
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roqua-core-api-0.0.29 lib/roqua/core_api/dossiers.rb
roqua-core-api-0.0.28 lib/roqua/core_api/dossiers.rb
roqua-core-api-0.0.27 lib/roqua/core_api/dossiers.rb
roqua-core-api-0.0.26 lib/roqua/core_api/dossiers.rb
roqua-core-api-0.0.25 lib/roqua/core_api/dossiers.rb