Class: ClientSideValidations::ORM::ValidateOptions
- Inherits:
-
Object
- Object
- ClientSideValidations::ORM::ValidateOptions
- Defined in:
- lib/client_side_validations/orm.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
Instance Method Summary collapse
-
#initialize(base) ⇒ ValidateOptions
constructor
A new instance of ValidateOptions.
- #to_hash ⇒ Object
- #validations_for(field) ⇒ Object
Constructor Details
#initialize(base) ⇒ ValidateOptions
Returns a new instance of ValidateOptions.
16 17 18 |
# File 'lib/client_side_validations/orm.rb', line 16 def initialize(base) self.base = base end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
14 15 16 |
# File 'lib/client_side_validations/orm.rb', line 14 def base @base end |
Instance Method Details
#to_hash ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/client_side_validations/orm.rb', line 20 def to_hash rules = Hash.new { |h, field| h[field] = {} } = Hash.new { |h, field| h[field] = {} } base.validation_fields.each do |field| validations = validations_for(field) rules[field.to_s].merge!(extract_rules(validations, field)) [field.to_s].merge!((validations)) end {"rules" => rules, "messages" => } end |
#validations_for(field) ⇒ Object
31 32 33 |
# File 'lib/client_side_validations/orm.rb', line 31 def validations_for(field) adapter.validations_to_hash(field) end |