module Paymill::Restful::All
Public Instance Methods
all( arguments = {} )
click to toggle source
# File lib/paymill/restful/methods.rb, line 5 def all( arguments = {} ) unless arguments.empty? order = "#{arguments[:order].map{ |e| "order=#{e.id2name}" }.join( '&' )}" if arguments[:order] filters = arguments[:filters].map{ |hash| hash.map{ |key, value| "#{key.id2name}=#{value.gsub( ' ', '+' ) }" }.join( '&' ) } if arguments[:filters] count = "count=#{arguments[:count]}" if arguments[:count] offset = "offset=#{arguments[:offset]}" if arguments[:offset] arguments = "?#{[order, filters, offset, count].reject { |e| e.nil? }.join( '&' )}" else arguments = '' end response = Paymill.request( Http.all( Restful.demodulize_and_tableize( name ), arguments ) ) enrich_array_with_data_count( response['data'].map!{ |element| new( element ) }, response['data_count'] ) end
Private Instance Methods
enrich_array_with_data_count( array, data_count )
click to toggle source
# File lib/paymill/restful/methods.rb, line 21 def enrich_array_with_data_count( array, data_count ) array.instance_variable_set( '@data_count', data_count ) def array.data_count @data_count end array end