Class: SlimValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- SlimValidator
- Defined in:
- lib/slim_validation.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attr_name, value) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/slim_validation.rb', line 7 def validate_each(record, attr_name, value) result = Slim::Template.new([:options]) { value }.render([:scope] == :record ? record : [:scope]) rescue record.errors.add(attr_name, :invalid_slim, ) ensure if (to = [:to]).present? to.is_a?(Proc) ? to.(record, result) : record[to] = result end end |