8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/filthy.rb', line 8
def filthy_attributes(*args)
raise ArgumentError if args.empty?
class_attribute :filthy_columns, :filthy_attribute_methods
if defined?(self.superclass.filthy_columns) && self.superclass.filthy_columns.present?
self.filthy_columns = args + self.superclass.filthy_columns
else
self.filthy_columns = args
end
self.filthy_attribute_methods = self.filthy_columns.collect { |attribute| :"#{attribute}_filthy" }
self.filthy_attribute_methods.each do |method|
attr_accessor method
send(:define_method, :"#{method}?") do
!!send(method)
end
end
end
|