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.



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

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



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

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



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

def attr_reader(*)
end

.attr_writerObject



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

def attr_writer(*)
end

.model_nameObject



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

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

.model_name=(name) ⇒ Object



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

def model_name=(name)
  @_active_model_sucks = name
end

.validates(*args, &block) ⇒ Object



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

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