Sha256: bdc7b34eb7344fb0f8adddaa6570c0bf9fac2f5f96d7a7665354496d97ef0e36

Contents?: true

Size: 1.04 KB

Versions: 21

Compression:

Stored size: 1.04 KB

Contents

module Ecoportal
  module API
    class Internal
      # @attr_reader client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
      class PolicyGroups
        include Enumerable

        attr_reader :client

        # @param client [Common::Client] a `Common::Client` object that holds the configuration of the api connection.
        # @return [PolicyGroups] an instance object ready to make policy groups api requests.
        def initialize(client)
          @client = client
        end

        # Gets all the policy groups via api request.
        # @return [Enumerable<PolicyGroup>] an `Enumerable` with all the policy groups already wrapped as `PolicyGroup` objects.
        def get_all
          response = client.get("/policy_groups")
          Common::WrappedResponse.new(response, Internal::PolicyGroup)
        end

        def each(&block)
          return to_enum(:each) unless block
          get_all.each(&block)
        end
      end
    end
  end
end

require 'ecoportal/api/internal/policy_group'

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
ecoportal-api-0.4.1 lib/ecoportal/api/internal/policy_groups.rb