Module: ClientSideValidations::ActiveModel::Format

Defined in:
lib/client_side_validations/active_model/format.rb

Instance Method Summary collapse

Instance Method Details

#client_side_hash(model, attribute, force = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/client_side_validations/active_model/format.rb', line 3

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