From abeac7f6817995b813095bd7968343e52f679a85 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 4 Nov 2015 14:53:45 -0500 Subject: [PATCH] two more places: make it possible for plugins to add methods to classes that don't follow naming conventions --- lib/plugin/instance.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index 0b0493b6e22..2e341bf5788 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -49,7 +49,7 @@ class Plugin::Instance delegate :name, to: :metadata def add_to_serializer(serializer, attr, define_include_method=true, &block) - klass = "#{serializer.to_s.classify}Serializer".constantize + klass = "#{serializer.to_s.classify}Serializer".constantize rescue "#{serializer.to_s}Serializer".constantize klass.attributes(attr) unless attr.to_s.start_with?("include_") @@ -65,7 +65,7 @@ class Plugin::Instance # Extend a class but check that the plugin is enabled # for class methods use `add_class_method` def add_to_class(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_method, hidden_method_name, &block)