Parent

Class/Module Index [+]

Quicksearch

Shoulda::Matchers::ActiveModel::EnsureInclusionOfMatcher

@private

Public Class Methods

new(attribute) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 241
def initialize(attribute)
  super(attribute)
  @options = {}
  @array = nil
  @range = nil
  @minimum = nil
  @maximum = nil
  @low_message = nil
  @high_message = nil
end

Public Instance Methods

allow_blank(allow_blank = true) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 264
def allow_blank(allow_blank = true)
  @options[:allow_blank] = allow_blank
  self
end
allow_nil(allow_nil = true) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 269
def allow_nil(allow_nil = true)
  @options[:allow_nil] = allow_nil
  self
end
description() click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 292
def description
  "ensure inclusion of #{@attribute} in #{inspect_message}"
end
in_array(array) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 252
def in_array(array)
  @array = array
  self
end
in_range(range) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 257
def in_range(range)
  @range = range
  @minimum = range.first
  @maximum = range.max
  self
end
matches?(subject) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 296
def matches?(subject)
  super(subject)

  if @range
    @low_message  ||= :inclusion
    @high_message ||= :inclusion
    matches_for_range?
  elsif @array
    if matches_for_array?
      true
    else
      @failure_message = "#{@array} doesn't match array in validation"
      false
    end
  end
end
with_high_message(message) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 287
def with_high_message(message)
  @high_message = message if message
  self
end
with_low_message(message) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 282
def with_low_message(message)
  @low_message = message if message
  self
end
with_message(message) click to toggle source
# File lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb, line 274
def with_message(message)
  if message
    @low_message = message
    @high_message = message
  end
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.