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
- #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
33 34 35 36 37 38 39 |
# File 'lib/rails_edge_test/dsl/action.rb', line 33 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
24 25 26 |
# File 'lib/rails_edge_test/dsl/action.rb', line 24 def __edges @edges end |
#__let_handler ⇒ Object
28 29 30 |
# File 'lib/rails_edge_test/dsl/action.rb', line 28 def __let_handler @let_handler end |
#edge(description, &block) ⇒ Object
11 12 13 14 |
# File 'lib/rails_edge_test/dsl/action.rb', line 11 def edge(description, &block) edge = Edge.new(description, self) @edges[edge] = block end |
#generate(title, &block) ⇒ Object
20 21 22 |
# File 'lib/rails_edge_test/dsl/action.rb', line 20 def generate(title, &block) @let_handler.add_definition("generate_#{title}", &block) end |
#let(title, &block) ⇒ Object
16 17 18 |
# File 'lib/rails_edge_test/dsl/action.rb', line 16 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
43 44 45 |
# File 'lib/rails_edge_test/dsl/action.rb', line 43 def respond_to_missing?(method_name, include_private = false) controller.respond_to?(method_name) || super end |