Class: StubRequests::DSL::MethodDefinition
- Defined in:
- lib/stub_requests/dsl/method_definition.rb
Overview
Class DefineMethod generates method definition for a stubbed endpoint
Constant Summary collapse
- BLOCK_ARG =
"&block"
Instance Attribute Summary collapse
- #endpoint_id ⇒ Object readonly
- #route_params ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(endpoint_id, route_params) ⇒ MethodDefinition
constructor
Initialize a new endpoint of MethodDefinition.
-
#name ⇒ String
The name of this method.
- #to_s ⇒ Object (also: #to_str)
Constructor Details
#initialize(endpoint_id, route_params) ⇒ MethodDefinition
Initialize a new endpoint of StubRequests::DSL::MethodDefinition
31 32 33 34 |
# File 'lib/stub_requests/dsl/method_definition.rb', line 31 def initialize(endpoint_id, route_params) @endpoint_id = endpoint_id @route_params = route_params end |
Instance Attribute Details
#endpoint_id ⇒ Object (readonly)
19 20 21 |
# File 'lib/stub_requests/dsl/method_definition.rb', line 19 def endpoint_id @endpoint_id end |
#route_params ⇒ Object (readonly)
23 24 25 |
# File 'lib/stub_requests/dsl/method_definition.rb', line 23 def route_params @route_params end |
Instance Method Details
#name ⇒ String
The name of this method
42 43 44 |
# File 'lib/stub_requests/dsl/method_definition.rb', line 42 def name @name ||= "stub_#{endpoint_id}" end |
#to_s ⇒ Object Also known as: to_str
46 47 48 49 50 51 52 |
# File 'lib/stub_requests/dsl/method_definition.rb', line 46 def to_s <<~METHOD def #{name}(#{keywords}) StubRequests.stub_endpoint(:#{endpoint_id}, #{arguments}) end METHOD end |