Class: Fauna::Failure

Inherits:
Object
  • Object
show all
Defined in:
lib/fauna/errors.rb

Overview

Part of ErrorData. For more information, see the docs.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, description, field) ⇒ Failure

:nodoc:



168
169
170
171
172
# File 'lib/fauna/errors.rb', line 168

def initialize(code, description, field) # :nodoc:
  @code = code
  @description = description
  @field = field
end

Instance Attribute Details

#codeObject (readonly)

Failure code.



154
155
156
# File 'lib/fauna/errors.rb', line 154

def code
  @code
end

#descriptionObject (readonly)

Failure description.



156
157
158
# File 'lib/fauna/errors.rb', line 156

def description
  @description
end

#fieldObject (readonly)

Field of the failure in the instance.



158
159
160
# File 'lib/fauna/errors.rb', line 158

def field
  @field
end

Class Method Details

.from_hash(hash) ⇒ Object

:nodoc:



160
161
162
163
164
165
166
# File 'lib/fauna/errors.rb', line 160

def self.from_hash(hash) # :nodoc:
  Failure.new(
    ErrorHelpers.get_or_throw(hash, :code),
    ErrorHelpers.get_or_throw(hash, :description),
    ErrorHelpers.map_position(hash[:field]),
  )
end

Instance Method Details

#inspectObject

:nodoc:



174
175
176
# File 'lib/fauna/errors.rb', line 174

def inspect # :nodoc:
  "Failure(#{code.inspect}, #{description.inspect}, #{field.inspect})"
end