Sha256: 92f55e1a59e5a3841a46a659bd2e9222b7adb13b5307c7c9164756c5eda00c2e

Contents?: true

Size: 1002 Bytes

Versions: 3

Compression:

Stored size: 1002 Bytes

Contents

require_relative 'configuration'

module SpreeMultiVendor
  class Engine < Rails::Engine
    require 'spree/core'
    isolate_namespace Spree
    engine_name 'spree_multi_vendor'

    # use rspec for tests
    config.generators do |g|
      g.test_framework :rspec
    end

    initializer 'spree_multi_vendor.environment', before: :load_config_initializers do |_app|
      SpreeMultiVendor::Config = SpreeMultiVendor::Configuration.new
    end

    config.after_initialize do
      ::Spree::PermittedAttributes.product_attributes << :vendor_id if SpreeMultiVendor::Config[:vendorized_models].include?('product')
    end

    def self.activate
      Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
        Rails.configuration.cache_classes ? require(c) : load(c)
      end
    end

    def self.api_v1_available?
      @@api_v1_available ||= Gem::Specification.find_all_by_name('spree_api_v1').any?
    end

    config.to_prepare &method(:activate).to_proc
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_multi_vendor-2.5.0 lib/spree_multi_vendor/engine.rb
spree_multi_vendor-2.4.1 lib/spree_multi_vendor/engine.rb
spree_multi_vendor-2.4.0 lib/spree_multi_vendor/engine.rb