Sha256: 967bb9b71e868c9c1b8c702a07c4822fc3d5f595ce3f5c13e6c78aa48efb89eb

Contents?: true

Size: 1.9 KB

Versions: 56

Compression:

Stored size: 1.9 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|
      app.config.to_prepare do
        ActiveSupport.on_load :active_record do
          ActiveRecord::Base.extend(ActsAsPurchasable::Base)
          ActiveRecord::Base.extend(ActsAsPurchasableParent::Base)
          ActiveRecord::Base.extend(ActsAsSubscribable::Base)
          ActiveRecord::Base.extend(ActsAsSubscribableBuyer::Base)
        end
      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', 'logo.png', 'stripe.png']
    end

    initializer 'effective_orders.refund', after: :load_config_initializers do
      if EffectiveOrders.refund?
        unless (EffectiveOrders.mailer_admin.to_s.include?('@') rescue false)
          raise("config.mailer_admin must be present when refunds enabled.")
        end
      end
    end

    initializer 'effective_orders.stripe', after: :load_config_initializers do
      if EffectiveOrders.stripe?
        begin
          require 'stripe'
        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

56 entries across 56 versions & 1 rubygems

Version Path
effective_orders-6.19.1 lib/effective_orders/engine.rb
effective_orders-6.19.0 lib/effective_orders/engine.rb
effective_orders-6.18.4 lib/effective_orders/engine.rb
effective_orders-6.18.3 lib/effective_orders/engine.rb
effective_orders-6.18.2 lib/effective_orders/engine.rb
effective_orders-6.18.1 lib/effective_orders/engine.rb
effective_orders-6.18.0 lib/effective_orders/engine.rb
effective_orders-6.17.2 lib/effective_orders/engine.rb
effective_orders-6.17.1 lib/effective_orders/engine.rb
effective_orders-6.17.0 lib/effective_orders/engine.rb
effective_orders-6.16.4 lib/effective_orders/engine.rb
effective_orders-6.16.3 lib/effective_orders/engine.rb
effective_orders-6.16.2 lib/effective_orders/engine.rb
effective_orders-6.16.1 lib/effective_orders/engine.rb
effective_orders-6.16.0 lib/effective_orders/engine.rb
effective_orders-6.15.0 lib/effective_orders/engine.rb
effective_orders-6.14.6 lib/effective_orders/engine.rb
effective_orders-6.14.5 lib/effective_orders/engine.rb
effective_orders-6.14.4 lib/effective_orders/engine.rb
effective_orders-6.14.3 lib/effective_orders/engine.rb