Class: RspecGenerateDoc::Decorators::Action
- Inherits:
-
Object
- Object
- RspecGenerateDoc::Decorators::Action
- Defined in:
- lib/rspec_generate_doc/decorators/action.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
- #content_type ⇒ Object
- #content_type? ⇒ Boolean
- #host ⇒ Object
-
#initialize(data = {}) ⇒ Action
constructor
A new instance of Action.
- #request_fullpath ⇒ Object
- #request_method ⇒ Object
- #status ⇒ Object
- #status_message ⇒ Object
- #status_with_message ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Action
Returns a new instance of Action.
7 8 9 10 11 12 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 7 def initialize(data = {}) @name = (data[:name] || '').split('#').join(' ') @response = data[:response] @params = to_params(data[:api_params]) @options = OpenStruct.new(data[:options] || {}) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def params @params end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def response @response end |
Instance Method Details
#body ⇒ Object
46 47 48 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 46 def body @body ||= json_object.nil? ? response.body.to_s : JSON.pretty_generate(json_object) end |
#content_type ⇒ Object
38 39 40 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 38 def content_type @content_type ||= .content_type || response.content_type end |
#content_type? ⇒ Boolean
42 43 44 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 42 def content_type? content_type.present? end |
#host ⇒ Object
22 23 24 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 22 def host @host ||= .host || request.host end |
#request_fullpath ⇒ Object
18 19 20 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 18 def request_fullpath @request_fullpath ||= .original_fullpath || request.original_fullpath.split('?').first end |
#request_method ⇒ Object
14 15 16 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 14 def request_method @request_method ||= .request_method || request.request_method end |
#status ⇒ Object
26 27 28 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 26 def status @status ||= .status || response.status end |
#status_message ⇒ Object
30 31 32 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 30 def @status_message ||= . || response. end |
#status_with_message ⇒ Object
34 35 36 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 34 def @status_with_message ||= "#{status} #{}" end |