Class: Solidus::Migrations::RenameGateways

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

Constant Summary

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
# File 'lib/solidus/migrations/rename_gateways.rb', line 14

def initialize(gateway_mapping = DEFAULT_MAPPING)
  @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



24
25
26
27
28
# File 'lib/solidus/migrations/rename_gateways.rb', line 24

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

#upObject



18
19
20
21
22
# File 'lib/solidus/migrations/rename_gateways.rb', line 18

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