module ActiveRecord::ActsAsRelation::ClassMethods
Public Instance Methods
acts_as(model_name, scope = nil, options = {})
click to toggle source
# File lib/active_record/acts_as_relation.rb, line 10 def acts_as(model_name, scope = nil, options = {}) acts_as = ActsAs.new(model_name, scope, options) include ActiveRecord::ActsAsRelation::ActsAsModules[acts_as] instance_eval <<-EndCode, __FILE__, __LINE__ + 1 def acts_as_other_model? true end def acts_as_model_name "#{acts_as.name}".to_sym end EndCode end
Also aliased as: is_a
acts_as_association_name(model_name = nil)
click to toggle source
# File lib/active_record/acts_as_relation.rb, line 62 def acts_as_association_name(model_name = nil) model_name ||= name "as_#{model_name.to_s.demodulize.singularize.underscore}" end
acts_as_superclass(options = {})
click to toggle source
# File lib/active_record/acts_as_relation.rb, line 27 def acts_as_superclass(options = {}) association_name = (options[:as] || acts_as_association_name).to_sym class_eval do belongs_to association_name, polymorphic: true, dependent: :delete alias_method :specific, association_name alias_method :specific_class, :specific def method_missing(method, *arg, &block) if specific && specific.respond_to?(method) specific.send(method, *arg, &block) else super end end def is_a?(klass) (specific && specific.class == klass) ? true : super end alias_method :instance_of?, :is_a? alias_method :kind_of?, :is_a? end end
Also aliased as: is_a_superclass
is_a?(klass)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as_relation.rb, line 44 def is_a?(klass) (specific && specific.class == klass) ? true : super end
Also aliased as: acts_as?
method_missing(method, *arg, &block)
click to toggle source
Calls superclass method
# File lib/active_record/acts_as_relation.rb, line 36 def method_missing(method, *arg, &block) if specific && specific.respond_to?(method) specific.send(method, *arg, &block) else super end end