module Jsm::Callbacks::ClassMethods

Public Instance Methods

after(context, &block) click to toggle source

this method is to register a `after callback` to a jsm_callbacks

# File lib/jsm/callbacks.rb, line 28
def after(context, &block)
  pre_after(context, &block)
  callback = Jsm::Callbacks::Callback.new(:after, &block)
  self.jsm_callbacks[context].insert_callback(callback)
end
before(context, &block) click to toggle source

this method is to register a `before callback` to a jsm_callbacks

# File lib/jsm/callbacks.rb, line 19
def before(context, &block)

  pre_before(context, &block)
  callback = Jsm::Callbacks::Callback.new(:before, &block)
  jsm_callbacks[context] ||= Jsm::Callbacks::Chain.new(context)
  jsm_callbacks[context].insert_callback(callback)
end
jsm_callbacks() click to toggle source
# File lib/jsm/callbacks.rb, line 7
def jsm_callbacks
  @jsm_callbacks ||= Jsm::Callbacks::ChainCollection.new(self)
end
pre_after(context, &block) click to toggle source

override this to do something before method `after`

# File lib/jsm/callbacks.rb, line 15
def pre_after(context, &block)
end
pre_before(context, &block) click to toggle source

override this to do something before method `before`

# File lib/jsm/callbacks.rb, line 11
def pre_before(context, &block)
end
run_callback(context, *args, &block) click to toggle source
# File lib/jsm/callbacks.rb, line 34
def run_callback(context, *args, &block)
  self.jsm_callbacks[context].compile(*args, &block)
end