module Paymill::Restful
Private Class Methods
demodulize_and_tableize( name )
click to toggle source
# File lib/paymill/restful/methods.rb, line 65 def self.demodulize_and_tableize( name ) "#{name.split('::').last.downcase}s" end
normalize( parameters = {} )
click to toggle source
# File lib/paymill/restful/methods.rb, line 69 def self.normalize( parameters = {} ) attributes = {}.compare_by_identity parameters.each do |key, value| if value.is_a? Array value.each.with_index do |e, index| if e.is_a? Item e.instance_variables.each do |var| attributes["items[#{index}][#{var.to_s[1..-1]}]"] = e.instance_variable_get( var ) unless e.instance_variable_get( var ).to_s.empty? end else attributes["#{key.to_s}[]"] = e end end elsif value.is_a? Base attributes[key.to_s] = value.id elsif value.is_a? Time attributes[key.to_s] = value.to_i elsif value.is_a? Address value.instance_variables.each do |var| attributes["#{key.to_s}[#{var.to_s[1..-1]}]"] = value.instance_variable_get( var ) unless value.instance_variable_get( var ).to_s.empty? end else attributes[key.to_s] = value unless value.nil? end end attributes end