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

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Reform::Form::ActiveModel::Validations

#build_errors, included, #read_attribute_for_validation

Constructor Details

#initialize(form, name) ⇒ Validator

Returns a new instance of Validator.



58
59
60
61
# File 'lib/reform/form/active_model/validations.rb', line 58

def initialize(form, name)
  super(form)
  self.class.model_name = name # one of the many reasons why i will drop support for AM::V in 2.1.
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



63
64
65
# File 'lib/reform/form/active_model/validations.rb', line 63

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

Class Method Details

.cloneObject



53
54
55
# File 'lib/reform/form/active_model/validations.rb', line 53

def clone
  Class.new(self)
end

.model_nameObject



45
46
47
# File 'lib/reform/form/active_model/validations.rb', line 45

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

.model_name=(name) ⇒ Object



49
50
51
# File 'lib/reform/form/active_model/validations.rb', line 49

def model_name=(name)
  @_active_model_sucks = name
end