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.



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

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



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

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



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

def attr_reader(*)
end

.attr_writerObject



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

def attr_writer(*)
end

.model_nameObject



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

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

.model_name=(name) ⇒ Object



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

def model_name=(name)
  @_active_model_sucks = name
end

.validates(*args, &block) ⇒ Object



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

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