Class: ValidatesBySchema::ValidationOption
- Inherits:
-
Object
- Object
- ValidatesBySchema::ValidationOption
- Defined in:
- lib/validates_by_schema/validation_option.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
column here must be an ActiveRecord column i.e.
-
#klass ⇒ Object
column here must be an ActiveRecord column i.e.
Instance Method Summary collapse
- #define! ⇒ Object
-
#initialize(klass, column) ⇒ ValidationOption
constructor
A new instance of ValidationOption.
Constructor Details
#initialize(klass, column) ⇒ ValidationOption
Returns a new instance of ValidationOption.
6 7 8 9 |
# File 'lib/validates_by_schema/validation_option.rb', line 6 def initialize(klass, column) @klass = klass @column = column end |
Instance Attribute Details
#column ⇒ Object
column here must be an ActiveRecord column i.e. MyARModel.columns.first
4 5 6 |
# File 'lib/validates_by_schema/validation_option.rb', line 4 def column @column end |
#klass ⇒ Object
column here must be an ActiveRecord column i.e. MyARModel.columns.first
4 5 6 |
# File 'lib/validates_by_schema/validation_option.rb', line 4 def klass @klass end |
Instance Method Details
#define! ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/validates_by_schema/validation_option.rb', line 11 def define! if association klass.validates association.name, presence: true unless column.null else = to_hash klass.validates column.name, if .present? end end |