Class: ForeignKeyValidation::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/foreign_key_validation/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opt = {}) ⇒ Validator

Returns a new instance of Validator.



7
8
9
10
11
# File 'lib/foreign_key_validation/validator.rb', line 7

def initialize(opt={})
  self.validate_against_key = opt[:validate_against_key]
  self.reflection_names     = opt[:reflection_names] || []
  self.object               = opt[:object]
end

Instance Attribute Details

#objectObject

Returns the value of attribute object.



5
6
7
# File 'lib/foreign_key_validation/validator.rb', line 5

def object
  @object
end

#reflection_namesObject

Returns the value of attribute reflection_names.



5
6
7
# File 'lib/foreign_key_validation/validator.rb', line 5

def reflection_names
  @reflection_names
end

#validate_against_keyObject

Returns the value of attribute validate_against_key.



5
6
7
# File 'lib/foreign_key_validation/validator.rb', line 5

def validate_against_key
  @validate_against_key
end

Instance Method Details

#validateObject



13
14
15
# File 'lib/foreign_key_validation/validator.rb', line 13

def validate
  to_enum(:invalid_reflection_names).map {|n| attach_error(n) }.any?
end