Class: Objective::Errors::ErrorAtom

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, codes, options = {}) ⇒ ErrorAtom

ErrorAtom.new(:name, :too_short) ErrorAtom.new(:name, :too_short, message: “is too short”)



9
10
11
12
13
14
15
16
# File 'lib/objective/errors/error_atom.rb', line 9

def initialize(key, codes, options = {})
  @key = key # attribute
  @codes = codes
  @message = options[:message]
  @type = options[:type] # target class/filter of coercion
  @value = options[:value] # value given
  @bound = options[:bound] # value of validator
end

Instance Attribute Details

#boundObject (readonly)

Returns the value of attribute bound.



5
6
7
# File 'lib/objective/errors/error_atom.rb', line 5

def bound
  @bound
end

#codesObject (readonly)

Returns the value of attribute codes.



5
6
7
# File 'lib/objective/errors/error_atom.rb', line 5

def codes
  @codes
end

#datumObject (readonly)

Returns the value of attribute datum.



5
6
7
# File 'lib/objective/errors/error_atom.rb', line 5

def datum
  @datum
end

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/objective/errors/error_atom.rb', line 5

def key
  @key
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/objective/errors/error_atom.rb', line 5

def type
  @type
end

Instance Method Details

#message(parent_key = nil, index = nil) ⇒ Object



18
19
20
# File 'lib/objective/errors/error_atom.rb', line 18

def message(parent_key = nil, index = nil)
  @message ||= Objective.error_message_creator.message(self, parent_key, index)
end

#message_list(parent_key = nil, index = nil) ⇒ Object



22
23
24
# File 'lib/objective/errors/error_atom.rb', line 22

def message_list(parent_key = nil, index = nil)
  Array.wrap(message(parent_key, index))
end