class Mambu::ApiModel
Public Class Methods
api_uri()
click to toggle source
# File lib/mambu/api_model.rb, line 14 def self.api_uri name.demodulize.downcase.pluralize end
endpoint(connection)
click to toggle source
# File lib/mambu/api_model.rb, line 10 def self.endpoint(connection) "#{connection.api_url}/#{api_uri}" end
new(data)
click to toggle source
# File lib/mambu/api_model.rb, line 3 def initialize(data) data.each do |method_name, value| self.class.send(:attr_accessor, method_name) unless self.class.method_defined?(method_name) send("#{method_name}=", convert_decimal(value)) end end
Public Instance Methods
convert_decimal(value)
click to toggle source
# File lib/mambu/api_model.rb, line 18 def convert_decimal(value) return value unless (value.is_a? String) && (value =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/) value.to_d end