Sha256: 4d5ced5382d208a40af9b3f1498dd805c6458b2ee7b4e8ea4c68c5f124746f4b

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module SpreeVeritrans
  class Engine < Rails::Engine
    engine_name 'spree_veritrans'

    config.autoload_paths += %W(#{config.root}/lib)

    initializer "spree.gateway.payment_methods", :after => "spree.register.payment_methods" do |app|
      app.config.spree.payment_methods << Spree::Gateway::VeritransGateway
    end

    def self.activate
      if SpreeVeritrans::Engine.frontend_available?
        Rails.application.config.assets.precompile += [
          'lib/assets/javascripts/spree/frontend/spree_veritrans.js',
          'lib/assets/javascripts/spree/frontend/spree_veritrans.css',
        ]
        Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/frontend/*/*_decorator*.rb")) do |c|
          Rails.configuration.cache_classes ? require(c) : load(c)
        end
      end
    end

    def self.backend_available?
      @@backend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Backend::Engine')
    end

    def self.frontend_available?
      @@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine')
    end

    if self.backend_available?
      paths["app/views"] << "lib/views/backend"
    end

    if self.frontend_available?
      paths["app/controllers"] << "lib/controllers/frontend"
      paths["app/views"] << "lib/views/frontend"
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_veritrans-1.0.0 lib/spree_veritrans/engine.rb