class Omise::OmiseObject
Attributes
endpoint[RW]
Public Class Methods
location(id = nil)
click to toggle source
# File lib/omise/object.rb, line 11 def location(id = nil) [endpoint, id].compact.join("/") end
resource(path, attributes = {})
click to toggle source
# File lib/omise/object.rb, line 15 def resource(path, attributes = {}) key = attributes.delete(:key) { resource_key } preprocess_attributes!(attributes) Omise.resource.new(resource_url, path, key) end
Private Class Methods
collection()
click to toggle source
# File lib/omise/object.rb, line 23 def collection self end
preprocess_attributes!(attributes)
click to toggle source
# File lib/omise/object.rb, line 32 def preprocess_attributes!(attributes) if attributes[:card].is_a?(Hash) require "omise/token" card_attributes = attributes.delete(:card) attributes[:card] = Token.create(card: card_attributes).id end end
resource_key()
click to toggle source
# File lib/omise/object.rb, line 44 def resource_key Omise.secret_api_key end
resource_url()
click to toggle source
# File lib/omise/object.rb, line 40 def resource_url Omise.api_url end
singleton!()
click to toggle source
# File lib/omise/object.rb, line 27 def singleton! require "omise/singleton_resource" include SingletonResource end
Private Instance Methods
collection()
click to toggle source
# File lib/omise/object.rb, line 51 def collection self.class end
nested_resource(path, *args)
click to toggle source
# File lib/omise/object.rb, line 59 def nested_resource(path, *args) collection.resource([location, path].compact.join("/"), *args) end
resource(*args)
click to toggle source
# File lib/omise/object.rb, line 55 def resource(*args) collection.resource(location, *args) end