Class: Flok::PopHooksDSLEnv
- Inherits:
-
Object
- Object
- Flok::PopHooksDSLEnv
- Defined in:
- lib/flok/user_hook_generators/pop.rb
Instance Attribute Summary collapse
-
#after_view_spider ⇒ Object
Returns the value of attribute after_view_spider.
-
#before_view_spider ⇒ Object
Returns the value of attribute before_view_spider.
-
#selectors ⇒ Object
Returns the value of attribute selectors.
Instance Method Summary collapse
- #after_views(spider) ⇒ Object
- #before_views(spider) ⇒ Object
- #controller(name) ⇒ Object
- #from_action(*names) ⇒ Object
-
#from_action_responds_to?(responds) ⇒ Boolean
The previous / next action contains an event handler for…
-
#initialize ⇒ PopHooksDSLEnv
constructor
A new instance of PopHooksDSLEnv.
- #triggered_by(event_name) ⇒ Object
Constructor Details
#initialize ⇒ PopHooksDSLEnv
Returns a new instance of PopHooksDSLEnv.
5 6 7 8 9 |
# File 'lib/flok/user_hook_generators/pop.rb', line 5 def initialize @selectors = [] @before_view_spider = {} @after_view_spider = {} end |
Instance Attribute Details
#after_view_spider ⇒ Object
Returns the value of attribute after_view_spider.
3 4 5 |
# File 'lib/flok/user_hook_generators/pop.rb', line 3 def after_view_spider @after_view_spider end |
#before_view_spider ⇒ Object
Returns the value of attribute before_view_spider.
3 4 5 |
# File 'lib/flok/user_hook_generators/pop.rb', line 3 def before_view_spider @before_view_spider end |
#selectors ⇒ Object
Returns the value of attribute selectors.
3 4 5 |
# File 'lib/flok/user_hook_generators/pop.rb', line 3 def selectors @selectors end |
Instance Method Details
#after_views(spider) ⇒ Object
57 58 59 |
# File 'lib/flok/user_hook_generators/pop.rb', line 57 def after_views spider @after_view_spider = spider end |
#before_views(spider) ⇒ Object
53 54 55 |
# File 'lib/flok/user_hook_generators/pop.rb', line 53 def before_views spider @before_view_spider = spider end |
#controller(name) ⇒ Object
11 12 13 |
# File 'lib/flok/user_hook_generators/pop.rb', line 11 def controller name @selectors << ->(p) { p["controller_name"] and p["controller_name"] == name.to_s } end |
#from_action(*names) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/flok/user_hook_generators/pop.rb', line 35 def from_action *names @selectors << lambda do |params| from_action = params["from_action"] next names.include? from_action end end |
#from_action_responds_to?(responds) ⇒ Boolean
The previous / next action contains an event handler for…
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/flok/user_hook_generators/pop.rb', line 17 def from_action_responds_to? responds @selectors << lambda do |params| from_action = params["from_action"] actions_respond_to = params["actions_responds_to"] #This is a hash that maps all actions to sensetivity lists #Get the sensetivity list if possible for this action (this is the list of events this action responds to) if actions_respond_to[from_action] sensetivity_list = actions_respond_to[from_action] #Does the sensetivity list include the event we are interested in? next sensetivity_list.include? responds end #The action wasn't even listed on the list, i.e. it has no sensetivity list next false end end |
#triggered_by(event_name) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/flok/user_hook_generators/pop.rb', line 43 def triggered_by event_name @selectors << lambda do |params| handling_event_named = params["handling_event_named"] next handling_event_named == event_name end end |