17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/delta_attributes4/main.rb', line 17
def delta_attributes(*args)
@_delta_attributes ||= Set.new
return @_delta_attributes if args.empty?
args.each do |attribute|
if self.columns_hash[attribute.to_s].blank?
raise InvalidDeltaColumn.new("#{self.to_s} model doesn't have attribute with name '#{attribute}.")
end
if self.columns_hash[attribute.to_s] && !self.columns_hash[attribute.to_s].number?
raise InvalidDeltaColumn.new("Delta attributes only work with number attributes, column `#{attribute}` is not a number.")
end
@_delta_attributes.add(attribute.to_s)
end
end
|