Class: RailsEdgeTest::Dsl::Action
- Inherits:
-
Struct
- Object
- Struct
- RailsEdgeTest::Dsl::Action
- Defined in:
- lib/rails_edge_test/dsl/action.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #__edges ⇒ Object
- #__let_handler ⇒ Object
- #controller_class ⇒ Object
- #edge(description, &block) ⇒ Object
- #generate(title, &block) ⇒ Object
-
#initialize(*args) ⇒ Action
constructor
A new instance of Action.
- #let(title, &block) ⇒ Object
-
#method_missing(method_name, *arguments, &block) ⇒ Object
support calling methods defined in controller.
-
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
always define respond_to_missing? when defining method_missing: thoughtbot.com/blog/always-define-respond-to-missing-when-overriding.
Constructor Details
#initialize(*args) ⇒ Action
Returns a new instance of Action.
3 4 5 6 7 |
# File 'lib/rails_edge_test/dsl/action.rb', line 3 def initialize(*args) super @edges = {} @let_handler = LetHandler.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
support calling methods defined in controller
35 36 37 38 39 40 41 |
# File 'lib/rails_edge_test/dsl/action.rb', line 35 def method_missing(method_name, *arguments, &block) if controller.respond_to?(method_name) controller.public_send(method_name, *arguments, &block) else super end end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller
2 3 4 |
# File 'lib/rails_edge_test/dsl/action.rb', line 2 def controller @controller end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/rails_edge_test/dsl/action.rb', line 2 def name @name end |
Instance Method Details
#__edges ⇒ Object
22 23 24 |
# File 'lib/rails_edge_test/dsl/action.rb', line 22 def __edges @edges end |
#__let_handler ⇒ Object
26 27 28 |
# File 'lib/rails_edge_test/dsl/action.rb', line 26 def __let_handler @let_handler end |
#controller_class ⇒ Object
30 31 32 |
# File 'lib/rails_edge_test/dsl/action.rb', line 30 def controller_class controller.controller_class end |
#edge(description, &block) ⇒ Object
9 10 11 12 |
# File 'lib/rails_edge_test/dsl/action.rb', line 9 def edge(description, &block) edge = Edge.new(description, self) @edges[edge] = block end |
#generate(title, &block) ⇒ Object
18 19 20 |
# File 'lib/rails_edge_test/dsl/action.rb', line 18 def generate(title, &block) @let_handler.add_definition("generate_#{title}", &block) end |
#let(title, &block) ⇒ Object
14 15 16 |
# File 'lib/rails_edge_test/dsl/action.rb', line 14 def let(title, &block) @let_handler.add_definition(title, &block) end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
always define respond_to_missing? when defining method_missing: thoughtbot.com/blog/always-define-respond-to-missing-when-overriding
45 46 47 |
# File 'lib/rails_edge_test/dsl/action.rb', line 45 def respond_to_missing?(method_name, include_private = false) controller.respond_to?(method_name) || super end |