lib/roda.rb
def plugin(plugin, *args, &block)
          raise RodaError, "Cannot add a plugin to a frozen Roda class" if frozen?
          plugin = RodaPlugins.load_plugin(plugin) if plugin.is_a?(Symbol)
          raise RodaError, "Invalid plugin type: #{plugin.class.inspect}" unless plugin.is_a?(Module)

          if !plugin.respond_to?(:load_dependencies) && !plugin.respond_to?(:configure) && (!args.empty? || block)
            # RODA4: switch from warning to error
            RodaPlugins.warn("Plugin #{plugin} does not accept arguments or a block, but arguments or a block was passed when loading this. This will raise an error in Roda 4.")
          end

          plugin.load_dependencies(self, *args, &block) if plugin.respond_to?(:load_dependencies)
          include(plugin::InstanceMethods) if defined?(plugin::InstanceMethods)
          extend(plugin::ClassMethods) if defined?(plugin::ClassMethods)
          self::RodaRequest.send(:include, plugin::RequestMethods) if defined?(plugin::RequestMethods)
          self::RodaRequest.extend(plugin::RequestClassMethods) if defined?(plugin::RequestClassMethods)
          self::RodaResponse.send(:include, plugin::ResponseMethods) if defined?(plugin::ResponseMethods)
          self::RodaResponse.extend(plugin::ResponseClassMethods) if defined?(plugin::ResponseClassMethods)
          plugin.configure(self, *args, &block) if plugin.respond_to?(:configure)
          @app = nil
        end
# Load a new plugin into the current class.  A plugin can be a module
# which is used directly, or a symbol representing a registered plugin
# which will be required and then used. Returns nil.
#
# Note that you should not load plugins into a Roda class after the
# class has been subclassed, as doing so can break the subclasses.
#
#   Roda.plugin PluginModule
#   Roda.plugin :csrf
Load a new plugin into the current class.  A plugin can be a module
which is used directly, or a symbol representing a registered plugin
which will be required and then used. Returns nil.

Note that you should not load plugins into a Roda class after the
class has been subclassed, as doing so can break the subclasses.


Load a new plugin into the current class . A plugin can be a module which is used directly or a symbol representing a registered plugin which will be required and then used . Returns nil . Note that you should not load plugins into a Roda class after the class has been subclassed as doing so can break the subclasses .
def plugin(plugin, *args, &block)
          raise RodaError, "Cannot add a plugin to a frozen Roda class" if frozen?
          plugin = RodaPlugins.load_plugin(plugin) if plugin.is_a?(Symbol)
          raise RodaError, "Invalid plugin type: #{plugin.class.inspect}" unless plugin.is_a?(Module)
          if !plugin.respond_to?(:load_dependencies) && !plugin.respond_to?(:configure) && (!args.empty? || block)
            RodaPlugins.warn("Plugin #{plugin} does not accept arguments or a block, but arguments or a block was passed when loading this. This will raise an error in Roda 4.")
          end
          plugin.load_dependencies(self, *args, &block) if plugin.respond_to?(:load_dependencies)
          include(plugin::InstanceMethods) if defined?(plugin::InstanceMethods)
          extend(plugin::ClassMethods) if defined?(plugin::ClassMethods)
          self::RodaRequest.send(:include, plugin::RequestMethods) if defined?(plugin::RequestMethods)
          self::RodaRequest.extend(plugin::RequestClassMethods) if defined?(plugin::RequestClassMethods)
          self::RodaResponse.send(:include, plugin::ResponseMethods) if defined?(plugin::ResponseMethods)
          self::RodaResponse.extend(plugin::ResponseClassMethods) if defined?(plugin::ResponseClassMethods)
          plugin.configure(self, *args, &block) if plugin.respond_to?(:configure)
          @app = nil
        end
def plugin ( plugin , * args , & block ) raise RodaError , "Cannot add a plugin to a frozen Roda class" if frozen? plugin = RodaPlugins . load_plugin ( plugin ) if plugin . is_a? ( Symbol ) raise RodaError , "Invalid plugin type: #{plugin.class.inspect}" unless plugin . is_a? ( Module ) if ! plugin . respond_to? ( :load_dependencies ) && ! plugin . respond_to? ( :configure ) && ( ! args . empty? || block ) RodaPlugins . warn ( "Plugin #{plugin} does not accept arguments or a block, but arguments or a block was passed when loading this. This will raise an error in Roda 4." ) end plugin . load_dependencies ( self , * args , & block ) if plugin . respond_to? ( :load_dependencies ) include ( plugin :: InstanceMethods ) if defined? ( plugin :: InstanceMethods ) extend ( plugin :: ClassMethods ) if defined? ( plugin :: ClassMethods ) self :: RodaRequest . send ( :include , plugin :: RequestMethods ) if defined? ( plugin :: RequestMethods ) self :: RodaRequest . extend ( plugin :: RequestClassMethods ) if defined? ( plugin :: RequestClassMethods ) self :: RodaResponse . send ( :include , plugin :: ResponseMethods ) if defined? ( plugin :: ResponseMethods ) self :: RodaResponse . extend ( plugin :: ResponseClassMethods ) if defined? ( plugin :: ResponseClassMethods ) plugin . configure ( self , * args , & block ) if plugin . respond_to? ( :configure ) @app = nil end
Load a new plugin into the current class.
Load a new plugin into the current class .
# RODA4: switch from warning to error
plugin
args
block