Class: Schematic::Generator::ColumnValidator
- Inherits:
-
Object
- Object
- Schematic::Generator::ColumnValidator
- Defined in:
- lib/schematic/generator/column_validator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #for_validator(validator_klass) ⇒ Object
-
#initialize(klass, column) ⇒ ColumnValidator
constructor
A new instance of ColumnValidator.
- #validators_for_column ⇒ Object
Constructor Details
#initialize(klass, column) ⇒ ColumnValidator
Returns a new instance of ColumnValidator.
6 7 8 9 |
# File 'lib/schematic/generator/column_validator.rb', line 6 def initialize(klass, column) @klass = klass @column = column end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
4 5 6 |
# File 'lib/schematic/generator/column_validator.rb', line 4 def column @column end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/schematic/generator/column_validator.rb', line 4 def klass @klass end |
Instance Method Details
#for_validator(validator_klass) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/schematic/generator/column_validator.rb', line 11 def for_validator(validator_klass) validators_for_column.each do |column_validation| next unless column_validation.is_a? validator_klass has_conditional_proc = !column_validation.[:if].nil? || !column_validation.[:unless].nil? force_inclusion = column_validation.[:xsd] && column_validation.[:xsd][:include] next if has_conditional_proc && !force_inclusion yield(column_validation) return end end |
#validators_for_column ⇒ Object
22 23 24 25 |
# File 'lib/schematic/generator/column_validator.rb', line 22 def validators_for_column return [] unless klass.respond_to?(:_validators) klass._validators[column.name.to_sym] end |