Class: Form::ActiveModel::Validations::Validator

Inherits:
SimpleDelegator
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/reform/form/active_model/validations.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ Validator

Returns a new instance of Validator.



228
229
230
231
# File 'lib/reform/form/active_model/validations.rb', line 228

def initialize(form)
  super(form)
  self.class.model_name = form.model_name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



233
234
235
# File 'lib/reform/form/active_model/validations.rb', line 233

def method_missing(m, *args, &block)
  __getobj__.send(m, *args, &block) # send all methods to the form, even privates.
end

Class Method Details

.attr_readerObject

Prevent AM:V from mutating the validator class



221
222
# File 'lib/reform/form/active_model/validations.rb', line 221

def attr_reader(*)
end

.attr_writerObject



224
225
# File 'lib/reform/form/active_model/validations.rb', line 224

def attr_writer(*)
end

.model_nameObject



208
209
210
# File 'lib/reform/form/active_model/validations.rb', line 208

def model_name
  @_active_model_sucks ||= ActiveModel::Name.new(Reform::Form, nil, "Reform::Form")
end

.model_name=(name) ⇒ Object



212
213
214
# File 'lib/reform/form/active_model/validations.rb', line 212

def model_name=(name)
  @_active_model_sucks = name
end

.validates(*args, &block) ⇒ Object



216
217
218
# File 'lib/reform/form/active_model/validations.rb', line 216

def validates(*args, &block)
  super(*Declarative::DeepDup.(args), &block)
end