Class: Apipie::ErrorDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/apipie/error_description.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/apipie/error_description.rb', line 5

def code
  @code
end

#descriptionObject (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_jsonObject



19
20
21
# File 'lib/apipie/error_description.rb', line 19

def to_json
  {:code => code, :description => description}
end