Class: ValidatesDuplicityOf::Duplicator
- Inherits:
-
Object
- Object
- ValidatesDuplicityOf::Duplicator
- Defined in:
- lib/validates_duplicity_of/duplicator.rb
Instance Method Summary collapse
-
#initialize(callback, record) ⇒ Duplicator
constructor
A new instance of Duplicator.
-
#validate ⇒ Object
Updates the attribute of the record.
Constructor Details
#initialize(callback, record) ⇒ Duplicator
Returns a new instance of Duplicator.
3 4 5 6 |
# File 'lib/validates_duplicity_of/duplicator.rb', line 3 def initialize(callback, record) @callback = callback @record = Record.new record, callback.attr_name, callback.scope end |
Instance Method Details
#validate ⇒ Object
Updates the attribute of the record
9 10 11 12 13 14 15 16 17 |
# File 'lib/validates_duplicity_of/duplicator.rb', line 9 def validate return unless @record.update_required? if changed_attribute_match? @record.attr_value = @record.attr_changed_value else @record.attr_value.concat(next_index) end end |