Class: FactPulse::Helpers::ValidationErrorDetail

Inherits:
Object
  • Object
show all
Defined in:
lib/factpulse/helpers/exceptions.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level: '', item: '', reason: '', source: nil, code: nil) ⇒ ValidationErrorDetail

Returns a new instance of ValidationErrorDetail.



12
# File 'lib/factpulse/helpers/exceptions.rb', line 12

def initialize(level: '', item: '', reason: '', source: nil, code: nil); @level, @item, @reason, @source, @code = level, item, reason, source, code; end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



11
12
13
# File 'lib/factpulse/helpers/exceptions.rb', line 11

def code
  @code
end

#itemObject

Returns the value of attribute item.



11
12
13
# File 'lib/factpulse/helpers/exceptions.rb', line 11

def item
  @item
end

#levelObject

Returns the value of attribute level.



11
12
13
# File 'lib/factpulse/helpers/exceptions.rb', line 11

def level
  @level
end

#reasonObject

Returns the value of attribute reason.



11
12
13
# File 'lib/factpulse/helpers/exceptions.rb', line 11

def reason
  @reason
end

#sourceObject

Returns the value of attribute source.



11
12
13
# File 'lib/factpulse/helpers/exceptions.rb', line 11

def source
  @source
end

Class Method Details

.from_hash(h) ⇒ Object



14
# File 'lib/factpulse/helpers/exceptions.rb', line 14

def self.from_hash(h); new(level: h['level']||'', item: h['item']||'', reason: h['reason']||'', source: h['source'], code: h['code']); end

Instance Method Details

#to_sObject



13
# File 'lib/factpulse/helpers/exceptions.rb', line 13

def to_s; "[#{@item.to_s.empty? ? 'unknown' : @item}] #{@reason.to_s.empty? ? 'Unknown error' : @reason}"; end