Class: Apipie::ErrorDescription
- Inherits:
-
Object
- Object
- Apipie::ErrorDescription
- Defined in:
- lib/apipie/error_description.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code_or_options, desc = nil, options = {}) ⇒ ErrorDescription
constructor
A new instance of ErrorDescription.
- #to_json(lang) ⇒ Object
Constructor Details
#initialize(code_or_options, desc = nil, options = {}) ⇒ ErrorDescription
Returns a new instance of ErrorDescription.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/apipie/error_description.rb', line 11 def initialize(, desc = nil, = {}) if .is_a? Hash .symbolize_keys! @code = [:code] @metadata = [:meta] @description = [:desc] || [:description] else @code = if .is_a? Symbol begin Rack::Utils.status_code() rescue ArgumentError nil end else end raise UnknownCode, unless @code @metadata = [:meta] @description = desc end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/apipie/error_description.rb', line 4 def code @code end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/apipie/error_description.rb', line 4 def description @description end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
4 5 6 |
# File 'lib/apipie/error_description.rb', line 4 def @metadata end |
Class Method Details
.from_dsl_data(args) ⇒ Object
6 7 8 9 |
# File 'lib/apipie/error_description.rb', line 6 def self.from_dsl_data(args) , desc, = args Apipie::ErrorDescription.new(, desc, ) end |