Class: Gruf::Errors::Field

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

Overview

Represents a field-specific error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field_name, error_code, message = '') ⇒ Field



36
37
38
39
40
# File 'lib/gruf/errors/field.rb', line 36

def initialize(field_name, error_code, message = '')
  @field_name = field_name
  @error_code = error_code
  @message = message
end

Instance Attribute Details

#error_codeSymbol (readonly)



27
28
29
# File 'lib/gruf/errors/field.rb', line 27

def error_code
  @error_code
end

#field_nameSymbol (readonly)



25
26
27
# File 'lib/gruf/errors/field.rb', line 25

def field_name
  @field_name
end

#messageString (readonly)



29
30
31
# File 'lib/gruf/errors/field.rb', line 29

def message
  @message
end

Instance Method Details

#to_hHash

Return the field error represented as a hash



47
48
49
50
51
52
53
# File 'lib/gruf/errors/field.rb', line 47

def to_h
  {
    field_name: field_name,
    error_code: error_code,
    message: message
  }
end