Sha256: 34b3c6b769c4c1b85f928fc29f3b7764b52524f108ee18c603195e188ffff714

Contents?: true

Size: 1.83 KB

Versions: 35

Compression:

Stored size: 1.83 KB

Contents

module EffectiveOrders
  class Engine < ::Rails::Engine
    engine_name 'effective_orders'

    config.autoload_paths += Dir["#{config.root}/app/models/**/"]

    # Include acts_as_addressable concern and allow any ActiveRecord object to call it
    initializer 'effective_orders.active_record' do |app|
      ActiveSupport.on_load :active_record do
        ActiveRecord::Base.extend(ActsAsPurchasable::ActiveRecord)
        ActiveRecord::Base.extend(ActsAsSubscribable::ActiveRecord)
        ActiveRecord::Base.extend(ActsAsSubscribableBuyer::ActiveRecord)
      end
    end

    # Set up our default configuration options.
    initializer 'effective_orders.defaults', before: :load_config_initializers do |app|
      eval File.read("#{config.root}/config/effective_orders.rb")
    end

    # Set up mail delivering config option
    initializer 'effective_orders.mailer', after: :load_config_initializers do |app|
      EffectiveOrders.mailer[:deliver_method] ||= (
        (Rails.application.config.respond_to?(:active_job) && Rails.application.config.active_job.queue_adapter) ? :deliver_later : :deliver_now
      )
    end

    initializer 'effective_orders.stripe', after: :load_config_initializers do
      if EffectiveOrders.stripe?
        begin
          require 'stripe'
          ::Stripe.api_key = EffectiveOrders.stripe[:secret_key]
        rescue Exception
          raise "unable to load stripe. Plese add gem 'stripe' to your Gemfile and then 'bundle install'"
        end
      end
    end

    initializer 'effective_orders.obfuscate_order_ids' do
      if EffectiveOrders.obfuscate_order_ids
        begin
          require 'effective_obfuscation'
        rescue Exception
          raise "unable to load effective_obfuscation. Please add gem 'effective_obfuscation' to your Gemfile and then 'bundle install'"
        end
      end
    end

  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
effective_orders-4.2.2 lib/effective_orders/engine.rb
effective_orders-4.2.1 lib/effective_orders/engine.rb
effective_orders-4.2.0 lib/effective_orders/engine.rb
effective_orders-4.1.5 lib/effective_orders/engine.rb
effective_orders-4.1.4 lib/effective_orders/engine.rb
effective_orders-4.1.3 lib/effective_orders/engine.rb
effective_orders-4.1.2 lib/effective_orders/engine.rb
effective_orders-4.1.1 lib/effective_orders/engine.rb
effective_orders-4.1.0 lib/effective_orders/engine.rb
effective_orders-4.0.6 lib/effective_orders/engine.rb
effective_orders-4.0.5 lib/effective_orders/engine.rb
effective_orders-4.0.4 lib/effective_orders/engine.rb
effective_orders-4.0.3 lib/effective_orders/engine.rb
effective_orders-4.0.2 lib/effective_orders/engine.rb
effective_orders-4.0.1 lib/effective_orders/engine.rb
effective_orders-4.0.0 lib/effective_orders/engine.rb
effective_orders-4.0.0beta19 lib/effective_orders/engine.rb
effective_orders-4.0.0beta18 lib/effective_orders/engine.rb
effective_orders-4.0.0beta17 lib/effective_orders/engine.rb
effective_orders-4.0.0beta16 lib/effective_orders/engine.rb