module GarlandRails::Extend
Public Class Methods
included(base)
click to toggle source
# File lib/garland_rails/extend.rb, line 3 def self.included(base) base.extend(self) end
Public Instance Methods
has_many(name, scope = nil, options = {}, &extension)
click to toggle source
Calls superclass method
# File lib/garland_rails/extend.rb, line 7 def has_many(name, scope = nil, options = {}, &extension) name_superclass = name.to_s.classify.constantize.superclass if name_superclass == GarlandRails::Base # if there are no scope and there are some options, # scope will contain options, and we need to swap them if scope.class == Hash options = scope scope = nil end belongs_to_type = self.name scope = -> { where(belongs_to_type: belongs_to_type) } options = options.merge(foreign_key: "belongs_to_id") end super(name, scope, options, &extension) end