module Upmin::AutomaticDelegation::ClassMethods
Public Instance Methods
before_remove_const()
click to toggle source
Avoids reloading the model class when ActiveSupport clears autoloaded dependencies in development mode.
# File lib/upmin/automatic_delegation.rb, line 71 def before_remove_const end
delegatable?(method)
click to toggle source
# File lib/upmin/automatic_delegation.rb, line 50 def delegatable?(method) @test ||={} @test[method] ||= 0 @test[method] += 1 return false if @test[method] > 2 model_class? && model_class.respond_to?(method) end
delegate(method, *args)
click to toggle source
Calls superclass method
# File lib/upmin/automatic_delegation.rb, line 58 def delegate(method, *args) @delegated ||= [] @delegated << method.to_sym super(method, *args) end
delegated?(method)
click to toggle source
# File lib/upmin/automatic_delegation.rb, line 64 def delegated?(method) @delegated ||= [] return @delegated.include?(method.to_sym) end
method_missing(method, *args, &block)
click to toggle source
Proxies missing class methods to the source class.
Calls superclass method
# File lib/upmin/automatic_delegation.rb, line 44 def method_missing(method, *args, &block) return super unless delegatable?(method) model_class.send(method, *args, &block) end