Sha256: 195e6303c2535c90d11549c62da206b54035fb6c10672cdd6d2ca1f27f3bb185

Contents?: true

Size: 500 Bytes

Versions: 4

Compression:

Stored size: 500 Bytes

Contents

# encoding: utf-8

module ActiveCleaner
  module HelperMethods

    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

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activecleaner-0.3.1 lib/active_cleaner/helper_methods.rb
activecleaner-0.3.0 lib/active_cleaner/helper_methods.rb
activecleaner-0.2.0 lib/active_cleaner/helper_methods.rb
activecleaner-0.1.0 lib/active_cleaner/helper_methods.rb