Class: RspecGenerateDoc::Decorators::Action
- Inherits:
-
Object
- Object
- RspecGenerateDoc::Decorators::Action
- Defined in:
- lib/rspec_generate_doc/decorators/action.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#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.
-
#request_fullpath ⇒ Object
readonly
Returns the value of attribute request_fullpath.
-
#request_method ⇒ Object
readonly
Returns the value of attribute request_method.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_message ⇒ Object
readonly
Returns the value of attribute status_message.
Instance Method Summary collapse
- #body ⇒ Object
- #content_type? ⇒ Boolean
-
#initialize(data = {}) ⇒ Action
constructor
A new instance of Action.
- #status_with_message ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Action
Returns a new instance of Action.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 8 def initialize(data = {}) @name = (data[:name] || '').split('#').join(' ') @response = data[:response] @content_type = data[:content_type] || response.content_type @status = data[:status] || response.status @status_message = data[:status_message] || response. @host = data[:host] || request.host @request_method = data[:request_method] || request.request_method @request_fullpath = data[:request_fullpath] || request.original_fullpath.split('?').first @params = to_params(data[:api_params]) @options = OpenStruct.new(data[:options] || {}) end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def content_type @content_type end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def host @host end |
#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 |
#request_fullpath ⇒ Object (readonly)
Returns the value of attribute request_fullpath.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def request_fullpath @request_fullpath end |
#request_method ⇒ Object (readonly)
Returns the value of attribute request_method.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def request_method @request_method 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 |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def status @status end |
#status_message ⇒ Object (readonly)
Returns the value of attribute status_message.
6 7 8 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 6 def @status_message end |
Instance Method Details
#body ⇒ Object
29 30 31 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 29 def body @body ||= json_object.nil? ? response.body.to_s : JSON.pretty_generate(json_object) end |
#content_type? ⇒ Boolean
25 26 27 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 25 def content_type? content_type.present? end |
#status_with_message ⇒ Object
21 22 23 |
# File 'lib/rspec_generate_doc/decorators/action.rb', line 21 def "#{status} #{}" end |