Sha256: 48845577bcaa3a986425038d07eeaa8cedaad0e86ea6694713ddab102cc5cf66
Contents?: true
Size: 854 Bytes
Versions: 3
Compression:
Stored size: 854 Bytes
Contents
module ActiveRecord module ActsAs module ReflectionsWithActsAs def _reflections super.reverse_merge(acting_as_model._reflections) end end module ClassMethods def self.included(module_) module_.prepend ReflectionsWithActsAs end def validators_on(*args) super + acting_as_model.validators_on(*args) end def actables acting_as_model.where(actable_id: select(:id)) end def method_missing(method, *args, &block) if acting_as_model.respond_to?(method) result = acting_as_model.public_send(method, *args, &block) if result.is_a?(ActiveRecord::Relation) all.joins(acting_as_name.to_sym).merge(result) else result end else super end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems