5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/text_sanitizer/text_sanitizer.rb', line 5
def register_sanitizer op, hook=:before_validation, *opt_args
self.class.send :define_method, "#{op}_text" do |*args| validate_and_set_text_fields_for op, hook, args
end
self.class.send :define_method, "#{op}_formatter" do |*args| create_formatted_attribute op, args
end
send :define_method, "#{op}_text_fields" do attrs = self.send "text_fields_to_#{op}"
do_for_text_fields attrs, op
end
unless opt_args.empty? self.send "#{op}_text", *opt_args
end
end
|