module ActsAs

Constants

PREFIX
VERSION

Public Class Methods

included(base) click to toggle source
# File lib/acts_as.rb, line 8
def self.included(base)
  raise ActiveRecordOnly unless base < ActiveRecord::Base
  base.extend ClassMethods
end

Public Instance Methods

acts_as_field_match?(method) click to toggle source
# 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() click to toggle source
Calls superclass method
# 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) click to toggle source
Calls superclass method
# 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