Module: ClientSideValidations::ActiveModel::EnumerableValidator

Included in:
Exclusion, Inclusion
Defined in:
lib/client_side_validations/active_model.rb

Instance Method Summary collapse

Instance Method Details

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



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/client_side_validations/active_model.rb', line 135

def client_side_hash(model, attribute, force = nil)
  options = self.options.dup
  if options[:in].respond_to?(:call)
    if force
      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, options)
  end

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

  hash
end