Module: Enrich::AutoDelegate::ClassMethods
- Defined in:
- lib/enrich/auto_delegate.rb
Instance Method Summary collapse
-
#before_remove_const ⇒ Object
Avoids reloading the model class when ActiveSupport clears autoloaded dependencies in development mode.
- #delegatable?(method) ⇒ Boolean
-
#method_missing(method, *args, &block) ⇒ Object
Proxies missing class methods to the source class.
-
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Checks if the decorator responds to a class method, or is able to proxy it to the source class.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Proxies missing class methods to the source class.
27 28 29 30 31 |
# File 'lib/enrich/auto_delegate.rb', line 27 def method_missing(method, *args, &block) return super unless delegatable?(method) object_class.send(method, *args, &block) end |
Instance Method Details
#before_remove_const ⇒ Object
Avoids reloading the model class when ActiveSupport clears autoloaded dependencies in development mode.
46 47 |
# File 'lib/enrich/auto_delegate.rb', line 46 def before_remove_const end |
#delegatable?(method) ⇒ Boolean
40 41 42 |
# File 'lib/enrich/auto_delegate.rb', line 40 def delegatable?(method) object_class? && object_class.respond_to?(method) end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Checks if the decorator responds to a class method, or is able to proxy it to the source class.
35 36 37 |
# File 'lib/enrich/auto_delegate.rb', line 35 def respond_to_missing?(method, include_private = false) super || delegatable?(method) end |