Class: Reform::Contract::Errors

Inherits:
Object
  • Object
show all
Includes:
Merge
Defined in:
lib/reform/contract/errors.rb

Defined Under Namespace

Modules: Merge

Instance Method Summary collapse

Methods included from Merge

#merge!, #to_s

Constructor Details

#initializeErrors

Returns a new instance of Errors.



2
3
4
# File 'lib/reform/contract/errors.rb', line 2

def initialize(*)
  @errors = {}
end

Instance Method Details

#[](name) ⇒ Object

needed by Rails form builder.



40
41
42
# File 'lib/reform/contract/errors.rb', line 40

def [](name)
  @errors[name] || []
end

#add(field, message) ⇒ Object



26
27
28
29
# File 'lib/reform/contract/errors.rb', line 26

def add(field, message)
  @errors[field] ||= []
  @errors[field] << message
end

#empty?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/reform/contract/errors.rb', line 35

def empty?
  @errors.empty?
end

#messagesObject



31
32
33
# File 'lib/reform/contract/errors.rb', line 31

def messages
  @errors
end