Class: SpreeAmazonApi::Engine

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

Class Method Summary collapse

Class Method Details

.activateObject



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
# File 'lib/spree_amazon_api.rb', line 10

def self.activate
  # amazon_options = YAML.load(File.open(File.join(Rails.root,'config', 'amazon.yml')))[Rails.env]

  Spree::Config.searcher_class = Spree::Search::Amazon if Spree::Config.instance

  Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
    Rails.env.production? ? require(c) : load(c)
  end

  require File.join(File.dirname(__FILE__), "../lib/spree_ecs.rb")
  Ability.register_ability(AmazonAbility)



  AppConfiguration.class_eval do
    preference :redirect_to_amazon, :boolean,  :default => false
  end

  Spree::Config.class_eval do
    class << self
      def amazon_options
        @@amazon_options ||= YAML.load(File.open(File.join(Rails.root,'config', 'amazon.yml')))[Rails.env]

        @@amazon_options
      end
    end # end class << self
  end

  Amazon::Ecs.configure do |options|
    options[:aWS_access_key_id]        = Spree::Config.amazon_options[:configure][:aWS_access_key_id]
    options[:aWS_secret_key]           = Spree::Config.amazon_options[:configure][:aWS_secret_key]
    options[:response_group]           = Spree::Config.amazon_options[:configure][:response_group] || 'Large'
    options[:country]                  = Spree::Config.amazon_options[:configure][:country] || 'us'
  end

end