Class: CabezaDeTermo::ValidationMessages::Library

Inherits:
Object
  • Object
show all
Defined in:
lib/validation-messages/library.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Library

Returns a new instance of Library.



10
11
12
# File 'lib/validation-messages/library.rb', line 10

def initialize(&block)
	configure(&block) unless block.nil?
end

Class Method Details

.default(library = nil) ⇒ Object



3
4
5
6
# File 'lib/validation-messages/library.rb', line 3

def self.default(library = nil)
	@default_library = library unless library.nil?
	@default_library
end

Instance Method Details

#configure(&block) ⇒ Object



14
15
16
# File 'lib/validation-messages/library.rb', line 14

def configure(&block)
	LibraryConfigurationDSL.evaluate_on(self, &block)
end

#message_at(validation_name, &block) ⇒ Object



18
19
20
# File 'lib/validation-messages/library.rb', line 18

def message_at(validation_name, &block)
	messages[validation_name] = block
end

#message_block_for(validation_name) ⇒ Object



22
23
24
# File 'lib/validation-messages/library.rb', line 22

def message_block_for(validation_name)
	messages.fetch(validation_name)
end

#message_for(error) ⇒ Object



26
27
28
# File 'lib/validation-messages/library.rb', line 26

def message_for(error)
	message_block_for(error.validation).call(error)
end