make it possible for plugins to add methods to classes that don't follow naming conventions

This commit is contained in:
Neil Lalonde 2015-09-14 15:34:28 -04:00
parent a8b3010617
commit db1820f39c
1 changed files with 2 additions and 2 deletions

View File

@ -78,7 +78,7 @@ class Plugin::Instance
# Adds a class method to a class, respecting if plugin is enabled
def add_class_method(klass, attr, &block)
klass = klass.to_s.classify.constantize
klass = klass.to_s.classify.constantize rescue klass.to_s.constantize
hidden_method_name = :"#{attr}_without_enable_check"
klass.send(:define_singleton_method, hidden_method_name, &block)
@ -90,7 +90,7 @@ class Plugin::Instance
end
def add_model_callback(klass, callback, &block)
klass = klass.to_s.classify.constantize
klass = klass.to_s.classify.constantize rescue klass.to_s.constantize
plugin = self
# generate a unique method name