Class: SampleModels::AttributeSequence::UniquenessFilter
- Inherits:
-
Object
- Object
- SampleModels::AttributeSequence::UniquenessFilter
- Defined in:
- lib/sample_models/attribute_sequence.rb
Instance Method Summary collapse
-
#initialize(model, column, validation, input) ⇒ UniquenessFilter
constructor
A new instance of UniquenessFilter.
- #next ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(model, column, validation, input) ⇒ UniquenessFilter
Returns a new instance of UniquenessFilter.
174 175 176 177 |
# File 'lib/sample_models/attribute_sequence.rb', line 174 def initialize(model, column, validation, input) @model, @column, @validation, @input = model, column, validation, input end |
Instance Method Details
#next ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/sample_models/attribute_sequence.rb', line 179 def next v = @input.next unless @validation.config[:allow_nil] && v.nil? unless @validation.config[:allow_blank] && v.blank? until @model.unique?(@column.name, v) v = @input.next end end end v end |
#value ⇒ Object
191 192 193 |
# File 'lib/sample_models/attribute_sequence.rb', line 191 def value self.next end |