File: exclusion.rb

package info (click to toggle)
ruby-client-side-validations 3.2.6%2Bgh-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 672 kB
  • ctags: 510
  • sloc: ruby: 2,959; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 600 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
module ClientSideValidations::ActiveModel
  module Exclusion

    def client_side_hash(model, attribute, force = nil)
      if options[:in].respond_to?(:call)
        if force
          options = self.options.dup
          options[:in] = options[:in].call(model)
          hash = build_client_side_hash(model, attribute, options)
        else
          return
        end
      else
        hash = build_client_side_hash(model, attribute, self.options.dup)
      end

      if hash[:in].is_a?(Range)
        hash[:range] = hash[:in]
        hash.delete(:in)
      end

      hash
    end

  end
end