Class: SBF::Client::ErrorEntity
- Inherits:
-
Object
- Object
- SBF::Client::ErrorEntity
- Defined in:
- lib/stbaldricks/entities/lib/error.rb
Constant Summary collapse
- BAD_INPUT =
5007
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ ErrorEntity
constructor
A new instance of ErrorEntity.
- #to_hash ⇒ Object
- #to_json(*a) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ ErrorEntity
Returns a new instance of ErrorEntity.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/stbaldricks/entities/lib/error.rb', line 10 def initialize(data = {}) super() # In case null was explicitly passed in data ||= {} # Set all attributes @code = data[:code].freeze @type = data[:type].freeze @details = data[:details].freeze @fields = Set.new(data[:errors].empty? ? [] : data[:errors]).freeze end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/stbaldricks/entities/lib/error.rb', line 8 def code @code end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
8 9 10 |
# File 'lib/stbaldricks/entities/lib/error.rb', line 8 def details @details end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
8 9 10 |
# File 'lib/stbaldricks/entities/lib/error.rb', line 8 def fields @fields end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/stbaldricks/entities/lib/error.rb', line 8 def type @type end |
Instance Method Details
#to_hash ⇒ Object
23 24 25 |
# File 'lib/stbaldricks/entities/lib/error.rb', line 23 def to_hash {code: @code, type: @type, details: @details, fields: @fields.to_a} end |
#to_json(*a) ⇒ Object
27 28 29 |
# File 'lib/stbaldricks/entities/lib/error.rb', line 27 def to_json(*a) to_hash.to_json(*a) end |
#to_s ⇒ Object
31 32 33 34 35 |
# File 'lib/stbaldricks/entities/lib/error.rb', line 31 def to_s = "#{@code} - [#{@type}] #{@details}" << " details: #{@fields.to_a.join(', ')}" unless @fields.empty? end |