class ActiveMerchant::Billing::Response

Constants

ATTRIBUTES_FOR_MONGOID_OPTIONS_SERIALIZATION

Public Class Methods

demongoize(object) click to toggle source
# File lib/mongoid/active_merchant/billing_response.rb, line 39
def demongoize(object)
  return nil if object.blank?

  options = object['options'].symbolize_keys

  if options[:avs_result].present?
    options[:avs_result] = options[:avs_result].symbolize_keys
  end

  Response.new(
    object['success'],
    object['message'],
    object['params'],
    options
  )
end
evolve(object) click to toggle source
# File lib/mongoid/active_merchant/billing_response.rb, line 63
def evolve(object)
  raise 'querying on an ActiveMerchant::Billing::Response is unsupported at this time'
end
mongoize(object) click to toggle source
# File lib/mongoid/active_merchant/billing_response.rb, line 56
def mongoize(object)
  case object
  when Response then object.mongoize
  else object
  end
end

Public Instance Methods

as_json(*) click to toggle source
# File lib/mongoid/active_merchant/billing_response.rb, line 13
def as_json(*)
  options = ATTRIBUTES_FOR_MONGOID_OPTIONS_SERIALIZATION.reduce({}) do |result, attr|
    value = instance_variable_get(:"@#{attr}")
    value = send(attr) if value.nil? && respond_to?(attr)
    result[attr.to_s] = value unless value.nil?
    result
  end

  # ActiveMerchant::Billing::CvvResult doesn't take a hash to initialize,
  # but it sets the Response's cvv_result instance variable to a hash.
  options['cvv_result'] = @cvv_result['code'] if @cvv_result.present?

  {
    'success' => success?,
    'message' => message,
    'params' => params,
    'options' => options
  }
end
Also aliased as: mongoize
mongoize(*)
Alias for: as_json
to_json(*args) click to toggle source
# File lib/mongoid/active_merchant/billing_response.rb, line 34
def to_json(*args)
  as_json.to_json(*args)
end