class Detox::Validations::PossessionValidator

Constants

ERROR_MESSAGE

Public Instance Methods

check_validity!() click to toggle source
# File lib/detox/validations/possession.rb, line 20
def check_validity!
  raise ArgumentError, ERROR_MESSAGE if options[:target].blank?
end
validate_each(record, attribute, value) click to toggle source
# File lib/detox/validations/possession.rb, line 10
def validate_each(record, attribute, value)
  args = { :record => record,
           :attribute => attribute,
           :value => value,
           :message => options[:message] || :possession,
           :options => options.merge(:target => [options[:target]].flatten.join(", ")) }

  validate_values(args)
end

Private Instance Methods

values_valid?(values) click to toggle source
# File lib/detox/validations/possession.rb, line 25
def values_valid?(values)
  [options[:target]].flatten.all? { |t| values.include?(t) }
end