Sha256: 703ea331644621e2353f7284a2d51531e124b6461626d98f859f3a47c2bd06d5

Contents?: true

Size: 1.83 KB

Versions: 3

Compression:

Stored size: 1.83 KB

Contents

require 'alchemy_cms'
require 'solidus_core'
require 'solidus_backend'
require 'solidus_support'

module Alchemy
  module Solidus
    class Engine < ::Rails::Engine
      engine_name 'alchemy_solidus'

      config.to_prepare do
        Alchemy.register_ability ::Spree::Ability
        ::Spree::Ability.register_ability ::Alchemy::Permissions

        if Alchemy.user_class_name == 'Spree::User'
          require 'alchemy/solidus/spree_user_extension'
          Spree::User.include Alchemy::Solidus::SpreeUserExtension
        end

        if Alchemy.user_class_name == 'Alchemy::User'
          require 'alchemy/solidus/alchemy_user_extension'
          Alchemy::User.include Alchemy::Solidus::AlchemyUserExtension
          require 'alchemy/solidus/spree_admin_unauthorized_redirect'
        end

        if SolidusSupport.solidus_gem_version < Gem::Version.new('2.5')
          require 'alchemy/solidus/spree_custom_user_generator_fix'
          require 'alchemy/solidus/spree_install_generator_fix'
        end
      end

      # Fix for +belongs_to :bill_address+ in {Spree::UserAddressBook}
      # Solidus has this set to +false+ in {Spree::Base}, but {Alchemy::User} does not inherit from it.
      initializer 'alchemy_solidus.belongs_bill_address_fix' do
        if Alchemy.user_class_name == 'Alchemy::User'
          ActiveSupport.on_load(:active_record) do
            Alchemy::User.belongs_to_required_by_default = false
          end
        end
      end
      
      # In versions of Solidus prior to 2.8, we override the tabs partial
      # to pass a match_path value to each tab. (Version 2.8 is already
      # passing this option.) This option is used to configure the paths
      # for which a given tab is active.
      #
      if Spree.solidus_gem_version < Gem::Version.new('2.8')
        paths['app/views'] << 'lib/views'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alchemy-solidus-2.5.1 lib/alchemy/solidus/engine.rb
alchemy-solidus-2.5.0 lib/alchemy/solidus/engine.rb
alchemy-solidus-2.4.0 lib/alchemy/solidus/engine.rb