Sha256: e1daf8a2014a2b555aa8b4bcc1b2bb5510219c1f6a2a42a18f6b5edfc5f8ecb0

Contents?: true

Size: 1.86 KB

Versions: 20

Compression:

Stored size: 1.86 KB

Contents

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

    # 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::Base)
        ActiveRecord::Base.extend(ActsAsSubscribable::Base)
        ActiveRecord::Base.extend(ActsAsSubscribableBuyer::Base)
      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

    initializer 'effective_orders.assets' do |app|
      app.config.assets.precompile += ['effective_orders_manifest.js', 'effective_orders/*']
    end

    initializer 'effective_orders.refund', after: :load_config_initializers do
      if EffectiveOrders.refund?
        unless (EffectiveOrders.mailer[:admin_email].to_s.include?('@') rescue false)
          raise("config.mailer[:admin_email] must be present when refunds enabled.")
        end
      end
    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

20 entries across 20 versions & 1 rubygems

Version Path
effective_orders-5.2.0 lib/effective_orders/engine.rb
effective_orders-5.1.17 lib/effective_orders/engine.rb
effective_orders-5.1.16 lib/effective_orders/engine.rb
effective_orders-5.1.15 lib/effective_orders/engine.rb
effective_orders-5.1.14 lib/effective_orders/engine.rb
effective_orders-5.1.13 lib/effective_orders/engine.rb
effective_orders-5.1.12 lib/effective_orders/engine.rb
effective_orders-5.1.11 lib/effective_orders/engine.rb
effective_orders-5.1.10 lib/effective_orders/engine.rb
effective_orders-5.1.9 lib/effective_orders/engine.rb
effective_orders-5.1.8 lib/effective_orders/engine.rb
effective_orders-5.1.7 lib/effective_orders/engine.rb
effective_orders-5.1.6 lib/effective_orders/engine.rb
effective_orders-5.1.5 lib/effective_orders/engine.rb
effective_orders-5.1.4 lib/effective_orders/engine.rb
effective_orders-5.1.3 lib/effective_orders/engine.rb
effective_orders-5.1.2 lib/effective_orders/engine.rb
effective_orders-5.1.1 lib/effective_orders/engine.rb
effective_orders-5.1.0 lib/effective_orders/engine.rb
effective_orders-5.0.5 lib/effective_orders/engine.rb