Sha256: 2178204a07055852af916f83b8d184e9270afb4a71cdf4b2a61922b0f9207e60

Contents?: true

Size: 727 Bytes

Versions: 3

Compression:

Stored size: 727 Bytes

Contents

module Paymill
  module Operations
    module All
      module ClassMethods
        # Retrieves all available objects from the Paymill API
        #
        # @param [Hash] options Options to pass to the API
        # @return [Array] The available objects
        def all(options = {})
          response = Paymill.request(:get, "#{self.name.split("::").last.downcase}s/", options)
          results_from response
        end

        private
        def results_from(response)
          results = []
          response["data"].each do |obj|
            results << self.new(obj)
          end
          results
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paymill-0.5.1 lib/paymill/operations/all.rb
paymill-0.5.0 lib/paymill/operations/all.rb
paymill-0.4.0 lib/paymill/operations/all.rb