class Jsm::Callbacks::Callback

the purpose of this class is to store the block that will be used as callback e.g: Jsm::Callbacks::Callback.new(:before) do

put 'me awesome'

end

Constants

FILTER_TYPES

Attributes

filter_type[R]

Public Class Methods

new(filter_type, &block) click to toggle source

the allowed filter_type: :before, :after

# File lib/jsm/callbacks/callback.rb, line 12
def initialize(filter_type, &block)
  if FILTER_TYPES.include?(filter_type)
    @filter_type = filter_type
  else
    raise ArgumentError, "invalid type #{filter_type}, allowed: #{FILTER_TYPES.join(', ')}"
  end
  @block = block
end

Public Instance Methods

execute(*obj) click to toggle source

run callback

# File lib/jsm/callbacks/callback.rb, line 22
def execute(*obj)
  @block.call(*obj)
end