Class: SpreeEnhancedOptionTypes::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/spree_enhanced_option_types.rb

Class Method Summary collapse

Class Method Details

.activateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/spree_enhanced_option_types.rb', line 9

def self.activate
  # Activation logic goes here.  A good use for this is performing class_eval on classes that are defined
  # outside of the extension (so that monkey patches are not lost on subsequent requests in development mode.)
  lambda{
    Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
      Rails.env == "production" ? require(c) : load(c)
    end

    if Spree::Config.instance
      Spree::Config.set(:variants_partial => 'radio_sets')
    end
    
    Spree::BaseController.class_eval do
      helper VariantSelection
    end

    Numeric.class_eval do
      def sign_symbol
        if self > 0
          "+"
        elsif self < 0
          "-"
        else
          ""
        end
      end
    end

    Admin::PrototypesController.class_eval do
      before_filter :load_sortable

      def load_sortable
        render_to_string :partial => 'sortable_header'
      end
    end

  }
end