Sha256: 55327e548b739bf5da99f9a90625b9a1773af1259f0cc95dbf1796c77c979a04
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module ActiveRecord module ActsAs module InstanceMethods def acting_as?(other = nil) self.class.acting_as? other end def is_a?(klass) super || acting_as?(klass) end def actable_must_be_valid unless acting_as.valid? acting_as.errors.each do |att, message| errors.add(att, message) end end end protected :actable_must_be_valid def read_attribute(attr_name, *args, &block) if attribute_method?(attr_name) super else acting_as.read_attribute(attr_name, *args, &block) end end def write_attribute(attr_name, value, *args, &block) if attribute_method?(attr_name) super else acting_as.send(:write_attribute, attr_name, value, *args, &block) end end private :write_attribute def attributes acting_as.attributes.except(acting_as_reflection.type, acting_as_reflection.foreign_key).merge(super) end def respond_to?(name, include_private = false) super || acting_as.respond_to?(name) end def method_missing(method, *args, &block) if acting_as.respond_to?(method) acting_as.send(method, *args, &block) else super end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_record-acts_as-1.0.0.pre | lib/active_record/acts_as/instance_methods.rb |