Sha256: edc00bfdf2a153c7b47982e369e3d2435a20eb89ff9874cc1d966e0207783247
Contents?: true
Size: 1.23 KB
Versions: 11
Compression:
Stored size: 1.23 KB
Contents
require "omise/config" require "omise/attributes" module Omise class OmiseObject include Attributes class << self attr_accessor :endpoint def location(id = nil) [endpoint, id].compact.join("/") end def resource(path, attributes = {}) key = attributes.delete(:key) { resource_key } preprocess_attributes!(attributes) Omise.resource.new(resource_url, path, key) end private def collection self end def singleton! require "omise/singleton_resource" include SingletonResource end 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 def resource_url Omise.api_url end def resource_key Omise.secret_api_key end end private def collection self.class end def resource(*args) collection.resource(location, *args) end def nested_resource(path, *args) collection.resource([location, path].compact.join("/"), *args) end end end
Version data entries
11 entries across 11 versions & 1 rubygems