Skip to content

v0.4.0

Latest

Choose a tag to compare

@nerbyk nerbyk released this 12 Jan 17:39
· 7 commits to master since this release

v0.3.4...v0.4.0

ActiveFunction v0.4.0

1. Introduction of Modular Plugin System

Old ActiveFunction::Functions modules have been extracted into plugins system.

Example:

require "active_function"

ActiveFunction.config do
  plugin :callbacks
  plugin :strong_parameters
  plugin :rendering
end

More details in ActiveFunction README

2. Callbacks Extraction

Callbacks system now engined by ActiveFunctionCore::Plugins::Hooks module and it's DSL is available through ActiveFunction::Plugins::Callbacks plugin.

Example:

require "active_function"

ActiveFunction.config do
  plugin :callbacks
end

class YourClass < ActiveFunction::Base
  before_action :do_something_before, only: [:your_method]

  define_hooks_for :respond

  after_respond :do_something_after

  def your_method = response

  def respond
    # Method implementation here...
  end
end

More details in ActiveFunctionCore v0.2.2

ActiveFunctionCore v0.2.2

Hooks Plugin Introduced

Introduced standalone ActiveFunctionCore::Plugins::Hooks module that provides ActiveSupport::Callbacks like DSL for hooks through ::define_hooks_for to define before_[method_name] & after_[method_name] callbacks and redefine #method_name to execute callbacks around it.

Example:

class YourClass
  include ActiveFunction::Core::Plugins::Hooks

  define_hooks_for :your_method

  before_your_method :do_something_before
  after_your_method :do_something_after

  def your_method
    # Method implementation here...
  end

  private

  def do_something_before
    # Callback logic to execute before your_method
  end

  def do_something_after
    # Callback logic to execute after your_method
  end
end

More details in ActiveFunctionCore README