Sha256: 2628fbe719a0407ee0a95622ec3c32b274302b1eb5db482b654fd5858078ae60

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 KB

Contents

require 'r3_plugin_toolbox/extender/util'

module Rails3
  class Plugin
    class Extender
      module LoadHandler
        include ::Rails3::Plugin::Extender::Util

        def before type, &block
          type = type.to_sym
          raise ArgumentError, "#{type} is not a valid before hook" if !valid_before_hook? type
          load_handling :"before_#{type}", &block
        end

        def after type, &block
          type = type.to_sym
          raise ArgumentError, "#{type} is not a valid after hook" if !valid_after_hook? type
          load_handling :"after_#{type}", &block
        end

        def on_load type, &block    
          type = get_load_type type
          raise ArgumentError, "#{type} is not a valid load hook" if !valid_load_hook? type
          load_handling type, &block
        end
      
        def load_handling type, &block
          ActiveSupport.on_load type do
            extend Rails3::Plugin::Extender::DSL

            if block
              block.arity < 1 ? self.instance_eval(&block) : block.call(self)  
            end      
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
r3_plugin_toolbox-0.4.3 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.4.2 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.4.1 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.4.0 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.3.15 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.3.14 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.3.13 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.3.12 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.3.11 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.3.10 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.3.8 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.3.7 lib/r3_plugin_toolbox/extender/load_handler.rb
r3_plugin_toolbox-0.3.6 lib/r3_plugin_toolbox/extender/load_handler.rb