class Accountability::Types::BillingConfigurationTypes::BillingAddressType

Public Instance Methods

cast_value(value) click to toggle source
# File lib/accountability/types/billing_configuration_types.rb, line 32
def cast_value(value)
  case value
  when String
    decoded_value = ActiveSupport::JSON.decode(value)
    BillingAddress.new(decoded_value)
  when Hash
    BillingAddress.new(value)
  when BillingAddress
    value
  end
end
changed_in_place?(raw_old_value, new_value) click to toggle source
# File lib/accountability/types/billing_configuration_types.rb, line 59
def changed_in_place?(raw_old_value, new_value)
  cast_value(raw_old_value) != new_value
end
serialize(data) click to toggle source

Only serialize the attributes that we have defined and keep extraneous things like “errors” or “validation_context” from slipping into the database.

Calls superclass method
# File lib/accountability/types/billing_configuration_types.rb, line 47
def serialize(data)
  case data
  when Hash
    billing_address = BillingAddress.new(data)
    ActiveSupport::JSON.encode(billing_address.attributes)
  when BillingAddress
    ActiveSupport::JSON.encode(data.attributes)
  else
    super(data)
  end
end
type() click to toggle source
# File lib/accountability/types/billing_configuration_types.rb, line 28
def type
  :text
end