module Adama::Validator::ClassMethods

Public Instance Methods

validates_presence_of(*attributes) click to toggle source
# File lib/adama/validator.rb, line 8
def validates_presence_of(*attributes)
  # Assign the validator if it exists, ortherwise create a new one and
  # append it to the validators array
  unless validator = validators.find { |v| v.is_a? PresenceValidator }
    validator = PresenceValidator.new
    validators << validator
  end

  # Append the passed in attributes. This will result in a list
  # of unique attributes.
  validator.merge_new_attributes(*attributes)
end
validators() click to toggle source

Maintain an array of validators

# File lib/adama/validator.rb, line 22
def validators
  @validators ||= []
end