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.
Instance Method Summary collapse
-
#initialize(args) ⇒ ErrorDescription
constructor
A new instance of ErrorDescription.
- #to_json ⇒ Object
Constructor Details
#initialize(args) ⇒ ErrorDescription
Returns a new instance of ErrorDescription.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/apipie/error_description.rb', line 7 def initialize(args) if args.first.is_a? Hash args = args.first elsif args.count == 2 args = {:code => args.first, :description => args.second} else raise ArgumentError "ApipieError: Bad use of error method." end @code = args[:code] || args['code'] @description = args[:desc] || args[:description] || args['desc'] || args['description'] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/apipie/error_description.rb', line 5 def code @code end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/apipie/error_description.rb', line 5 def description @description end |
Instance Method Details
#to_json ⇒ Object
19 20 21 |
# File 'lib/apipie/error_description.rb', line 19 def to_json {:code => code, :description => description} end |