Module: ActsAs
- Defined in:
- lib/acts_as.rb,
lib/acts_as/version.rb
Defined Under Namespace
Modules: ClassMethods
Classes: ActiveRecordOnly
Constant Summary
collapse
- PREFIX =
%w(id created_at updated_at)
- VERSION =
"0.6.5"
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
8
9
10
11
|
# File 'lib/acts_as.rb', line 8
def self.included(base)
raise ActiveRecordOnly unless base < ActiveRecord::Base
base.extend ClassMethods
end
|
Instance Method Details
#acts_as_field_match?(method) ⇒ Boolean
30
31
32
33
|
# File 'lib/acts_as.rb', line 30
def acts_as_field_match?(method)
@association_match = self.class.acts_as_fields_match(method)
@association_match && send(@association_match).respond_to?(method)
end
|
#previous_changes ⇒ Object
13
14
15
16
17
18
|
# File 'lib/acts_as.rb', line 13
def previous_changes
self.class.acts_as_fields.keys.map{ |association| send(association).previous_changes }
.reduce(super) do |current, association_changes|
current.merge(association_changes)
end
end
|
#update_column(name, value) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/acts_as.rb', line 20
def update_column(name, value)
if attribute_names.include?(name.to_s)
super
elsif (association = self.class.acts_as_fields.detect { |k,v| v.include?(name.to_s) }.try(:first)).present?
send(association).update_column name, value
else
super
end
end
|