lib/flok/user_hook_generators/goto.rb in flok-0.0.103 vs lib/flok/user_hook_generators/goto.rb in flok-0.0.105
- old
+ new
@@ -1,7 +1,5 @@
-require_relative 'helpers'
-
module Flok
class GotoHooksDSLEnv
attr_accessor :selectors, :before_view_spider, :after_view_spider
def initialize
@@ -32,10 +30,17 @@
#The action wasn't even listed on the list, i.e. it has no sensetivity list
next false
end
end
+ def triggered_by event_name
+ @selectors << lambda do |params|
+ handling_event_named = params["handling_event_named"]
+ next handling_event_named == event_name
+ end
+ end
+
def to_action_responds_to? responds
@selectors << lambda do |params|
to_action = params["to_action"]
actions_respond_to = params["actions_responds_to"] #This is a hash that maps all actions to sensetivity lists
@@ -49,10 +54,27 @@
#The action wasn't even listed on the list, i.e. it has no sensetivity list
next false
end
end
+
+ def to_action *names
+ @selectors << lambda do |params|
+ to_action = params["to_action"]
+
+ next names.include? to_action
+ end
+ end
+
+ def from_action *names
+ @selectors << lambda do |params|
+ from_action = params["from_action"]
+
+ next names.include? from_action
+ end
+ end
+
#################################################################################
def before_views spider
@before_view_spider = spider
end
@@ -83,10 +105,10 @@
end
manifest << HooksManifestEntry.new("controller_did_goto", dsl_env.selectors) do |entry_hook_params|
next %{
//The completion callback will share a pointer to the views_to_free key index
- reg_evt(views_to_free_id, hook_goto_completion_cb);
+ reg_evt(views_to_free_id, hook_completion_cb);
var #{ns}_after_views = find_view(__base__, #{dsl_env.after_view_spider.to_json});
var #{ns}_info = {
views: #{ns}_after_views,
cep: views_to_free_id