Parent

Class/Module Index [+]

Quicksearch

Shoulda::Matchers::ActiveModel::ValidateUniquenessOfMatcher

@private

Public Class Methods

new(attribute) click to toggle source
# File lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb, line 178
def initialize(attribute)
  super(attribute)
  @options = {}
end

Public Instance Methods

allow_nil() click to toggle source
# File lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb, line 198
def allow_nil
  @options[:allow_nil] = true
  self
end
case_insensitive() click to toggle source
# File lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb, line 193
def case_insensitive
  @options[:case_insensitive] = true
  self
end
description() click to toggle source
# File lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb, line 203
def description
  result = "require "
  result << "case sensitive " unless @options[:case_insensitive]
  result << "unique value for #{@attribute}"
  result << " scoped to #{@options[:scopes].join(', ')}" if @options[:scopes].present?
  result
end
matches?(subject) click to toggle source
# File lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb, line 211
def matches?(subject)
  @subject = subject.class.new
  @expected_message ||= :taken
  set_scoped_attributes &&
    validate_everything_except_duplicate_nils? &&
    validate_after_scope_change? &&
    allows_nil?
end
scoped_to(*scopes) click to toggle source
# File lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb, line 183
def scoped_to(*scopes)
  @options[:scopes] = [*scopes].flatten
  self
end
with_message(message) click to toggle source
# File lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb, line 188
def with_message(message)
  @expected_message = message
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.