class Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher::AttributeSetters

@private

Public Class Methods

new() click to toggle source
# File lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb, line 931
def initialize
  @attribute_setters = []
end

Public Instance Methods

+(other_attribute_setters) click to toggle source
# File lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb, line 945
def +(other_attribute_setters)
  dup.tap do |attribute_setters|
    other_attribute_setters.each do |attribute_setter|
      attribute_setters << attribute_setter
    end
  end
end
<<(given_attribute_setter) click to toggle source
# File lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb, line 935
def <<(given_attribute_setter)
  index = find_index_of(given_attribute_setter)

  if index
    @attribute_setters[index] = given_attribute_setter
  else
    @attribute_setters << given_attribute_setter
  end
end
each(&block) click to toggle source
# File lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb, line 953
def each(&block)
  @attribute_setters.each(&block)
end
last() click to toggle source
# File lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb, line 957
def last
  @attribute_setters.last
end

Private Instance Methods

find_index_of(given_attribute_setter) click to toggle source
# File lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb, line 963
def find_index_of(given_attribute_setter)
  @attribute_setters.find_index do |attribute_setter|
    attribute_setter.attribute_name ==
      given_attribute_setter.attribute_name
  end
end