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) ⇒ Validator

Returns a new instance of Validator.



93
94
95
96
# File 'lib/reform/form/active_model/validations.rb', line 93

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



98
99
100
# File 'lib/reform/form/active_model/validations.rb', line 98

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



86
87
# File 'lib/reform/form/active_model/validations.rb', line 86

def attr_reader(*)
end

.attr_writerObject



89
90
# File 'lib/reform/form/active_model/validations.rb', line 89

def attr_writer(*)
end

.model_nameObject



73
74
75
# File 'lib/reform/form/active_model/validations.rb', line 73

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

.model_name=(name) ⇒ Object



77
78
79
# File 'lib/reform/form/active_model/validations.rb', line 77

def model_name=(name)
  @_active_model_sucks = name
end

.validates(*args, &block) ⇒ Object



81
82
83
# File 'lib/reform/form/active_model/validations.rb', line 81

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