Module: ActiveCleaner::HelperMethods

Defined in:
lib/active_cleaner/helper_methods.rb

Instance Method Summary collapse

Instance Method Details

#clean(*attr_names) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/active_cleaner/helper_methods.rb', line 6

def clean(*attr_names)
  options = attr_names.extract_options!.symbolize_keys
  attr_names.flatten!

  options[:as] ||= :string

  cleaner = "active_cleaner/#{options.delete(:as)}_cleaner".camelize.constantize

  attr_names.each do |attr_name|
    clean_with cleaner.new(attr_name, options)
  end
end

#clean_with(cleaner) ⇒ Object



19
20
21
# File 'lib/active_cleaner/helper_methods.rb', line 19

def clean_with(cleaner)
  self._cleaners[cleaner.attr_name] << cleaner
end