Class: GLiveValidator::ValidationDefinition
- Inherits:
-
Object
- Object
- GLiveValidator::ValidationDefinition
- Defined in:
- lib/g_live_validator/validation_definition.rb
Instance Attribute Summary collapse
-
#active_record ⇒ Object
Returns the value of attribute active_record.
-
#macro ⇒ Object
Returns the value of attribute macro.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(validation) ⇒ ValidationDefinition
constructor
A new instance of ValidationDefinition.
Constructor Details
#initialize(validation) ⇒ ValidationDefinition
Returns a new instance of ValidationDefinition.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/g_live_validator/validation_definition.rb', line 6 def initialize( validation ) if validation.is_a?(ActiveRecord::Reflection::MacroReflection ) self.active_record = validation.active_record self.macro = validation.macro self.name = validation.name self. = validation. elsif validation.is_a?( ValidationRule ) self.active_record = validation.entity_type.constantize self.macro = "validates_#{validation.validation}_of" self.name = validation.attribute self. = YAML.load( validation.description ) unless validation.description.nil? end end |
Instance Attribute Details
#active_record ⇒ Object
Returns the value of attribute active_record.
4 5 6 |
# File 'lib/g_live_validator/validation_definition.rb', line 4 def active_record @active_record end |
#macro ⇒ Object
Returns the value of attribute macro.
4 5 6 |
# File 'lib/g_live_validator/validation_definition.rb', line 4 def macro @macro end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/g_live_validator/validation_definition.rb', line 4 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/g_live_validator/validation_definition.rb', line 4 def @options end |