Class: Attestor::Validations::Validators Private
- Inherits:
-
Object
- Object
- Attestor::Validations::Validators
- Includes:
- Enumerable
- Defined in:
- lib/attestor/validations/validators.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.
The collection of validations used by class instances
Class Method Summary collapse
-
.add(name, options = {}) ⇒ Attestor::Validators
private
Returns validators updated by new item.
-
.each {|item| ... } ⇒ Enumerator
private
Iterates through the collection.
- .initialize(items = []) ⇒ Object private
-
.new(items = []) ⇒ Attestor::Validators
Creates an immutable collection with optional list of items.
-
.set(context) ⇒ Attestor::Validators
private
Returns validators used in given context.
Class Method Details
.add(name, options = {}) ⇒ Attestor::Validators
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 validators updated by new item
47 48 49 50 51 52 |
# File 'lib/attestor/validations/validators.rb', line 47 def add(name, = {}) item = Validator.new(name, ) return self if include? item self.class.new(@items + [item]) end |
.each {|item| ... } ⇒ Enumerator
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.
Iterates through the collection
34 35 36 |
# File 'lib/attestor/validations/validators.rb', line 34 def each block_given? ? @items.each { |item| yield(item) } : to_enum end |
.initialize(items = []) ⇒ 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.
22 23 24 25 |
# File 'lib/attestor/validations/validators.rb', line 22 def initialize(items = []) @items = items freeze end |
.new(items = []) ⇒ Attestor::Validators
Creates an immutable collection with optional list of items
|
|
# File 'lib/attestor/validations/validators.rb', line 13
|
.set(context) ⇒ Attestor::Validators
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 validators used in given context
59 60 61 62 63 |
# File 'lib/attestor/validations/validators.rb', line 59 def set(context) validators = select { |item| item.used_in_context? context } self.class.new(validators) end |