File: format.rb

package info (click to toggle)
ruby-client-side-validations 3.2.6%2Bgh-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 676 kB
  • sloc: javascript: 3,019; ruby: 2,959; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module ClientSideValidations::ActiveModel
  module Format
    def client_side_hash(model, attribute, force = nil)
      options = self.options.dup
      if options[:with].respond_to?(:call)
        if force
          options[:with] = options[:with].call(model)
          build_client_side_hash(model, attribute, options)
        else
          return
        end
      elsif options[:without].respond_to?(:call)
        if force
          options[:without] = options[:without].call(model)
          build_client_side_hash(model, attribute, options)
        else
          return
        end
      else
        super
      end
    end

    private

    def message_type
      :invalid
    end
  end
end