Class: Solidus::Migrations::RenameGateways

Inherits:
Object
  • Object
show all
Defined in:
lib/solidus/migrations/rename_gateways.rb

Constant Summary collapse

DEFAULT_MAPPING =
{
  'Spree::Gateway' => 'Spree::PaymentMethod::CreditCard',
  'Spree::Gateway::Bogus' => 'Spree::PaymentMethod::BogusCreditCard',
  'Spree::Gateway::BogusSimple' => 'Spree::PaymentMethod::SimpleBogusCreditCard'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gateway_mapping = DEFAULT_MAPPING) ⇒ RenameGateways

Returns a new instance of RenameGateways.



14
15
16
17
18
# File 'lib/solidus/migrations/rename_gateways.rb', line 14

def initialize(gateway_mapping = DEFAULT_MAPPING)
  Spree::Deprecation.warn 'Solidus::Migrations::RenameGateways is deprecated and will be removed with Solidus 3.0.'

  @gateway_mapping = gateway_mapping
end

Instance Attribute Details

#gateway_mappingObject (readonly)

Returns the value of attribute gateway_mapping.



12
13
14
# File 'lib/solidus/migrations/rename_gateways.rb', line 12

def gateway_mapping
  @gateway_mapping
end

Instance Method Details

#downObject



26
27
28
29
30
# File 'lib/solidus/migrations/rename_gateways.rb', line 26

def down
  gateway_mapping.inject(0) do |count, mapping|
    count + update(from: mapping[1], to: mapping[0])
  end
end

#upObject



20
21
22
23
24
# File 'lib/solidus/migrations/rename_gateways.rb', line 20

def up
  gateway_mapping.inject(0) do |count, mapping|
    count + update(from: mapping[0], to: mapping[1])
  end
end