Class: SpreeCore::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/spree_core/railtie.rb

Class Method Summary collapse

Class Method Details

.activateObject

TODO - register state monitor observer?



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/spree_core/railtie.rb', line 7

def self.activate

  Spree::ThemeSupport::HookListener.subclasses.each do |hook_class|
    Spree::ThemeSupport::Hook.add_listener(hook_class)
  end

  #register all payment methods (unless we're in middle of rake task since migrations cannot be run for this first time without this check)
  if File.basename( $0 ) != "rake"
    [
      Gateway::Bogus,
      Gateway::AuthorizeNet,
      Gateway::AuthorizeNetCim,
      Gateway::Eway,
      Gateway::Linkpoint,
      Gateway::PayPal,
      Gateway::SagePay,
      Gateway::Beanstream,
      Gateway::Braintree,
      PaymentMethod::Check
    ].each{|gw|
      begin
        gw.register
      rescue Exception => e
        $stderr.puts "Error registering gateway #{gw}: #{e}"
      end
    }

    #register all calculators
    [
      Calculator::FlatPercentItemTotal,
      Calculator::FlatRate,
      Calculator::FlexiRate,
      Calculator::PerItem,
      Calculator::SalesTax,
      Calculator::Vat,
      Calculator::PriceBucket
    ].each{|c_model|
      begin
        c_model.register if c_model.table_exists?
      rescue Exception => e
        $stderr.puts "Error registering calculator #{c_model}"
      end
    }

  end

end