Class: Flok::PushHooksDSLEnv
- Inherits:
-
Object
- Object
- Flok::PushHooksDSLEnv
- Defined in:
- lib/flok/user_hook_generators/push.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 ⇒ PushHooksDSLEnv
constructor
A new instance of PushHooksDSLEnv.
- #to_action(*names) ⇒ Object
- #to_action_responds_to?(responds) ⇒ Boolean
- #triggered_by(event_name) ⇒ Object
Constructor Details
#initialize ⇒ PushHooksDSLEnv
Returns a new instance of PushHooksDSLEnv.
5 6 7 8 9 |
# File 'lib/flok/user_hook_generators/push.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/push.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/push.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/push.rb', line 3 def selectors @selectors end |
Instance Method Details
#after_views(spider) ⇒ Object
82 83 84 |
# File 'lib/flok/user_hook_generators/push.rb', line 82 def after_views spider @after_view_spider = spider end |
#before_views(spider) ⇒ Object
78 79 80 |
# File 'lib/flok/user_hook_generators/push.rb', line 78 def before_views spider @before_view_spider = spider end |
#controller(name) ⇒ Object
11 12 13 |
# File 'lib/flok/user_hook_generators/push.rb', line 11 def controller name @selectors << ->(p) { p["controller_name"] and p["controller_name"] == name.to_s } end |
#from_action(*names) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/flok/user_hook_generators/push.rb', line 61 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/push.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 |
#to_action(*names) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/flok/user_hook_generators/push.rb', line 53 def to_action *names @selectors << lambda do |params| to_action = params["to_action"] next names.include? to_action end end |
#to_action_responds_to?(responds) ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/flok/user_hook_generators/push.rb', line 35 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 #Get the sensetivity list if possible for this action (this is the list of events this action responds to) if actions_respond_to[to_action] sensetivity_list = actions_respond_to[to_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
69 70 71 72 73 74 |
# File 'lib/flok/user_hook_generators/push.rb', line 69 def triggered_by event_name @selectors << lambda do |params| handling_event_named = params["handling_event_named"] next handling_event_named == event_name end end |