Class: SBF::Client::ErrorEntity
- Inherits:
- 
      Object
      
        - Object
- SBF::Client::ErrorEntity
 
- Defined in:
- lib/stbaldricks/entities/lib/error.rb
Direct Known Subclasses
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
- #empty? ⇒ Boolean
- 
  
    
      #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.
| 11 12 13 14 15 16 17 18 19 20 21 22 | # File 'lib/stbaldricks/entities/lib/error.rb', line 11 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.
| 9 10 11 | # File 'lib/stbaldricks/entities/lib/error.rb', line 9 def code @code end | 
#details ⇒ Object (readonly)
Returns the value of attribute details.
| 9 10 11 | # File 'lib/stbaldricks/entities/lib/error.rb', line 9 def details @details end | 
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
| 9 10 11 | # File 'lib/stbaldricks/entities/lib/error.rb', line 9 def fields @fields end | 
#type ⇒ Object (readonly)
Returns the value of attribute type.
| 9 10 11 | # File 'lib/stbaldricks/entities/lib/error.rb', line 9 def type @type end | 
Instance Method Details
#empty? ⇒ Boolean
| 24 25 26 | # File 'lib/stbaldricks/entities/lib/error.rb', line 24 def empty? [@code, @type, @details].all?(&:nil?) && @fields.empty? end | 
#to_hash ⇒ Object
| 28 29 30 | # File 'lib/stbaldricks/entities/lib/error.rb', line 28 def to_hash {code: @code, type: @type, details: @details, fields: @fields.to_a} end | 
#to_json(*a) ⇒ Object
| 32 33 34 | # File 'lib/stbaldricks/entities/lib/error.rb', line 32 def to_json(*a) to_hash.to_json(*a) end | 
#to_s ⇒ Object
| 36 37 38 39 40 | # File 'lib/stbaldricks/entities/lib/error.rb', line 36 def to_s = "#{@code} - [#{@type}] #{@details}" << " details: #{@fields.to_a.join(', ')}" unless @fields.empty? end |