Class: ActionSpec::Doc::Endpoint
- Inherits:
-
Object
- Object
- ActionSpec::Doc::Endpoint
- Defined in:
- lib/action_spec/doc/endpoint.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Instance Method Summary collapse
- #add_response(code, response) ⇒ Object
- #apply(block) ⇒ Object
- #copy ⇒ Object
- #dsl ⇒ Object
-
#initialize(action, summary: nil, options: {}) ⇒ Endpoint
constructor
A new instance of Endpoint.
Constructor Details
#initialize(action, summary: nil, options: {}) ⇒ Endpoint
Returns a new instance of Endpoint.
8 9 10 11 12 13 14 |
# File 'lib/action_spec/doc/endpoint.rb', line 8 def initialize(action, summary: nil, options: {}) @action = action.to_sym @summary = summary @options = @request = Request.new @responses = {} end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
6 7 8 |
# File 'lib/action_spec/doc/endpoint.rb', line 6 def action @action end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/action_spec/doc/endpoint.rb', line 6 def @options end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/action_spec/doc/endpoint.rb', line 6 def request @request end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
6 7 8 |
# File 'lib/action_spec/doc/endpoint.rb', line 6 def responses @responses end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
6 7 8 |
# File 'lib/action_spec/doc/endpoint.rb', line 6 def summary @summary end |
Instance Method Details
#add_response(code, response) ⇒ Object
25 26 27 28 |
# File 'lib/action_spec/doc/endpoint.rb', line 25 def add_response(code, response) existing = @responses[code.to_s] @responses[code.to_s] = existing ? existing.merge(response) : response end |
#apply(block) ⇒ Object
20 21 22 23 |
# File 'lib/action_spec/doc/endpoint.rb', line 20 def apply(block) dsl.instance_exec(&block) self end |
#copy ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/action_spec/doc/endpoint.rb', line 30 def copy self.class.new(action, summary:, options: .deep_dup).tap do |endpoint| endpoint.request.replace_with(request.copy) responses.each do |code, response| endpoint.add_response(code, response.copy) end end end |