Module: TextFilter::ClassMethods

Defined in:
lib/text_filter.rb

Instance Method Summary collapse

Instance Method Details

#text_filter(*args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/text_filter.rb', line 3

def text_filter(*args)
  options = args.extract_options![:with]
  args.each do |attribute|
    define_method "#{attribute}=" do |value|
      if value.is_a? String
        [*options].each do |method|
          if method.is_a? Hash
            method.each {|name, args| value = value.send(name, *args)}
          else
            value = value.send(method)
          end
        end
      end
      write_attribute attribute, value
    end
  end
end