Class: Lotus::Validations::ValidationSet Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/validations/validation_set.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A set of validations defined on an object

Since:

  • 0.2.2

Constant Summary collapse

VALIDATIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Allowed validations

Since:

  • 0.2.2

[
  :presence,
  :acceptance,
  :format,
  :inclusion,
  :exclusion,
  :confirmation,
  :size,
  :type,
  :nested
].freeze

Instance Method Summary collapse

Constructor Details

#initializeValidationSet

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ValidationSet.

Since:

  • 0.2.2



26
27
28
# File 'lib/lotus/validations/validation_set.rb', line 26

def initialize
  @validations = Hash.new {|h,k| h[k] = {} }
end

Instance Method Details

#add(name, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.2



32
33
34
35
36
# File 'lib/lotus/validations/validation_set.rb', line 32

def add(name, options)
  @validations[name.to_sym].merge!(
    validate_options!(name, options)
  )
end

#each(&blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.2



40
41
42
# File 'lib/lotus/validations/validation_set.rb', line 40

def each(&blk)
  @validations.each(&blk)
end

#each_key(&blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.2



46
47
48
# File 'lib/lotus/validations/validation_set.rb', line 46

def each_key(&blk)
  @validations.each_key(&blk)
end

#namesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.3



52
53
54
# File 'lib/lotus/validations/validation_set.rb', line 52

def names
  @validations.keys
end