Class: Flok::UserCompilerContext
- Inherits:
-
Object
- Object
- Flok::UserCompilerContext
- Defined in:
- lib/flok/user_compiler.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#controllers ⇒ Object
Returns the value of attribute controllers.
-
#ons ⇒ Object
Returns the value of attribute ons.
Instance Method Summary collapse
- #action(controller, name, &block) ⇒ Object
- #actions_for_controller(controller_name) ⇒ Object
-
#actions_respond_to ⇒ Object
actions_responds_to looks like {“action1” => [“event_a”, …“], ”action2“ => }…
- #controller(name, &block) ⇒ Object
- #get_binding ⇒ Object
-
#initialize ⇒ UserCompilerContext
constructor
A new instance of UserCompilerContext.
-
#might_respond_to ⇒ Object
Returns a list of events that this controller ‘might’ respond to Used for things like hook event handlers to provide queryable information.
- #on(controller_name, action_name, name, &block) ⇒ Object
- #spots_for_controller(controller_name) ⇒ Object
Constructor Details
#initialize ⇒ UserCompilerContext
Returns a new instance of UserCompilerContext.
30 31 32 33 34 35 36 |
# File 'lib/flok/user_compiler.rb', line 30 def initialize @controllers = [] @actions = [] @ons = [] @debug = ENV["FLOK_ENV"] ? true : false end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
28 29 30 |
# File 'lib/flok/user_compiler.rb', line 28 def actions @actions end |
#controllers ⇒ Object
Returns the value of attribute controllers.
28 29 30 |
# File 'lib/flok/user_compiler.rb', line 28 def controllers @controllers end |
#ons ⇒ Object
Returns the value of attribute ons.
28 29 30 |
# File 'lib/flok/user_compiler.rb', line 28 def ons @ons end |
Instance Method Details
#action(controller, name, &block) ⇒ Object
59 60 61 |
# File 'lib/flok/user_compiler.rb', line 59 def action controller, name, &block @actions << UserCompilerAction.new(controller, name, self, &block) end |
#actions_for_controller(controller_name) ⇒ Object
66 67 68 |
# File 'lib/flok/user_compiler.rb', line 66 def actions_for_controller controller_name return @actions.select{|e| e.controller.name == controller_name} end |
#actions_respond_to ⇒ Object
actions_responds_to looks like {“action1” => [“event_a”, …“], ”action2“ => }… where each action list contains all the events this action responds to
47 48 49 |
# File 'lib/flok/user_compiler.rb', line 47 def actions_respond_to @actions.map{|e| [e.name.to_s, e.ons.map{|e| e[:name].to_s}]}.to_h end |
#controller(name, &block) ⇒ Object
55 56 57 |
# File 'lib/flok/user_compiler.rb', line 55 def controller name, &block @controllers << UserCompilerController.new(name, self, &block) end |
#get_binding ⇒ Object
51 52 53 |
# File 'lib/flok/user_compiler.rb', line 51 def get_binding return binding end |
#might_respond_to ⇒ Object
Returns a list of events that this controller ‘might’ respond to Used for things like hook event handlers to provide queryable information.
41 42 43 |
# File 'lib/flok/user_compiler.rb', line 41 def might_respond_to @actions.map{|e| e.ons}.flatten.map{|e| e[:name]} end |
#on(controller_name, action_name, name, &block) ⇒ Object
63 64 |
# File 'lib/flok/user_compiler.rb', line 63 def on controller_name, action_name, name, &block end |
#spots_for_controller(controller_name) ⇒ Object
70 71 72 |
# File 'lib/flok/user_compiler.rb', line 70 def spots_for_controller controller_name return @controllers.detect{|e| e.name == controller_name}.spots end |