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”)



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

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.



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

def bound
  @bound
end

#codesObject (readonly)

Returns the value of attribute codes.



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

def codes
  @codes
end

#datumObject (readonly)

Returns the value of attribute datum.



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

def datum
  @datum
end

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

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



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

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



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

def message_list(parent_key = nil, index = nil)
  Objective::Helpers.wrap(message(parent_key, index))
end