Module: ActiveFunction

Defined in:
lib/active_function.rb,
lib/active_function/base.rb,
lib/active_function/version.rb,
lib/active_function/functions/response.rb,
lib/active_function/functions/callbacks.rb,
lib/active_function/functions/rendering.rb,
lib/active_function/functions/strong_parameters.rb

Defined Under Namespace

Modules: Functions Classes: Base, SuperBase

Constant Summary collapse

VERSION =
"0.4.2"

Class Method Summary collapse

Class Method Details

.config(&block) ⇒ void

This method returns an undefined value.

Configure ActiveFunction through DSL method calls. Setups Base with provided internal and custom plugins. Also freezes plugins and Base.

Examples:

ActiveFunction.config do
  plugin :callbacks
end

Parameters:

  • block (Proc)

    class_eval’ed block in ActiveFunction module.



22
23
24
25
26
# File 'lib/active_function.rb', line 22

def config(&block)
  class_eval(&block)
  @_plugins.freeze
  self::Base.freeze
end

.plugin(mod) ⇒ void

This method returns an undefined value.

Add plugin to ActiveFunction::Base.

Examples:

ActiveFunction.plugin :callbacks
ActiveFunction.plugin CustomPlugin

Parameters:

  • mod (Symbol, Module)


48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/active_function.rb', line 48

def plugin(mod)
  if mod.is_a? Symbol
    begin
      require "active_function/functions/#{mod}"
      mod = plugins.fetch(mod)
    rescue LoadError
      raise ArgumentError, "Unknown plugin #{mod}"
    end
  end

  self::Base.include(mod)
end

.pluginsObject

List of registered internal plugins.



29
# File 'lib/active_function.rb', line 29

def plugins = @_plugins ||= {}

.register_plugin(symbol, mod) ⇒ Object

Register internal Symbol’ed plugin.

Parameters:

  • symbol (Symbol)

    name of internal plugin, should match file name in ./lib/active_function/functions/*.rb

  • mod (Module)

    module to register.



36
37
38
# File 'lib/active_function.rb', line 36

def register_plugin(symbol, mod)
  plugins[symbol] = mod
end