module ActiveRecord::ActsAs::InstanceMethods
Public Instance Methods
_write_attribute(attr_name, value, *args, &block)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 47 def _write_attribute(attr_name, value, *args, &block) if attribute_method?(attr_name.to_s) super else acting_as.send(:_write_attribute, attr_name, value, *args, &block) end end
acting_as?(other = nil)
click to toggle source
# File lib/active_record/acts_as/instance_methods.rb, line 4 def acting_as?(other = nil) self.class.acting_as? other end
attribute_names()
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 76 def attribute_names super | (acting_as.attribute_names - [acting_as_reflection.type, acting_as_reflection.foreign_key]) end
attributes()
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 72 def attributes acting_as.attributes.except(acting_as_reflection.type, acting_as_reflection.foreign_key).merge(super) end
changed?()
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 16 def changed? super || acting_as.changed? || (defined?(@_acting_as_changed) ? @_acting_as_changed : false) end
column_for_attribute(name)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 88 def column_for_attribute(name) if has_attribute?(name, true) super(name) else acting_as.column_for_attribute(name) end end
dup()
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 114 def dup duplicate = super duplicate.acting_as = acting_as.dup duplicate end
has_attribute?(attr_name, as_original_class = false)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 80 def has_attribute?(attr_name, as_original_class = false) if as_original_class super(attr_name) else super(attr_name) || acting_as.has_attribute?(attr_name) end end
is_a?(klass)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 8 def is_a?(klass) super || acting_as?(klass) end
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 120 def method_missing(method, *args, &block) if !self_respond_to?(method) && acting_as.respond_to?(method) acting_as.send(method, *args, &block) else super end end
read_attribute(attr_name, *args, &block)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 31 def read_attribute(attr_name, *args, &block) if attribute_method?(attr_name.to_s) super else acting_as.read_attribute(attr_name, *args, &block) end end
read_store_attribute(store_attribute, key)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 55 def read_store_attribute(store_attribute, key) if attribute_method?(store_attribute.to_s) super else acting_as.send(:read_store_attribute, store_attribute, key) end end
respond_to?(name, include_private = false, as_original_class = false)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 102 def respond_to?(name, include_private = false, as_original_class = false) if as_original_class super(name, include_private) else super(name, include_private) || acting_as.respond_to?(name) end end
saved_changes?()
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 12 def saved_changes? super || acting_as.has_changes_to_save? || (defined?(@_acting_as_changed) ? @_acting_as_changed : false) end
self_respond_to?(name, include_private = false)
click to toggle source
# File lib/active_record/acts_as/instance_methods.rb, line 110 def self_respond_to?(name, include_private = false) respond_to? name, include_private, true end
touch(*args, time: nil)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 96 def touch(*args, time: nil) self_args, acting_as_args = args.partition { |arg| has_attribute?(arg, true) } super(*self_args, time: time) if self_args.any? acting_as.touch(*acting_as_args, time: time) if acting_as.persisted? end
Protected Instance Methods
actable_must_be_valid()
click to toggle source
# File lib/active_record/acts_as/instance_methods.rb, line 20 def actable_must_be_valid unless acting_as.valid? acting_as.errors.messages.each do |attribute, messages| messages.each do |message| errors.add(attribute, message) unless errors[attribute].include?(message) end end end end
Private Instance Methods
write_attribute(attr_name, value, *args, &block)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 39 def write_attribute(attr_name, value, *args, &block) if attribute_method?(attr_name.to_s) super else acting_as.send(:write_attribute, attr_name, value, *args, &block) end end
write_store_attribute(store_attribute, key, value)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as/instance_methods.rb, line 63 def write_store_attribute(store_attribute, key, value) if attribute_method?(store_attribute.to_s) super else acting_as.send(:write_store_attribute, store_attribute, key, value) end end