Module: Filthy::ClassMethods

Defined in:
lib/filthy.rb

Instance Method Summary collapse

Instance Method Details

#filthy_attributes(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/filthy.rb', line 8

def filthy_attributes(*args)
  class_variable_set(:@@filthy_attributes, args)
        
  class_variable_set(:@@filthy_attribute_methods, class_variable_get(:@@filthy_attributes).collect { |attribute| :"#{attribute}_filthy" })
  
  class_variable_get(:@@filthy_attribute_methods).each do |method|
    attr_accessor method
    
    send(:define_method, :"#{method}?") do
      !!send(method)
    end
  end
end