11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/micro/attributes/features/activemodel_validations.rb', line 11
def self.included(base)
if !@@__active_model_load_error && !@@__active_model_required
begin
require 'active_model'
rescue LoadError => e
@@__active_model_load_error = true
end
@@__active_model_required = true
end
unless @@__active_model_load_error
base.send(:include, ::ActiveModel::Validations)
if ::ActiveModel::VERSION::STRING >= V32
base.class_eval(<<-RUBY)
def initialize(arg)
self.attributes=arg
run_validations!
end
RUBY
end
end
end
|