[Git][noosfero/noosfero][master] plugin/manager: don't call method if not defined on plugin

Bráulio Bhavamitra gitlab at mg.gitlab.com
Sat May 20 11:13:13 BRT 2017


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
48bfeb64 by Braulio Bhavamitra at 2017-05-20T11:12:56-03:00
plugin/manager: don't call method if not defined on plugin

plugin/manager: call default as fallback

- - - - -


2 changed files:

- config/spring.rb
- lib/noosfero/plugin/manager.rb


Changes:

=====================================
config/spring.rb
=====================================
--- a/config/spring.rb
+++ b/config/spring.rb
@@ -3,7 +3,7 @@ paths = %w(
   .env.local
   .ruby-version
   .rbenv-vars
-  lib
+  lib/**
   tmp/restart.txt
   tmp/caching-dev.txt
   db/migrate


=====================================
lib/noosfero/plugin/manager.rb
=====================================
--- a/lib/noosfero/plugin/manager.rb
+++ b/lib/noosfero/plugin/manager.rb
@@ -34,25 +34,23 @@ class Noosfero::Plugin::Manager
   alias :dispatch_scopes :dispatch_without_flatten
 
   def dispatch_first(event, *args)
-    default = Noosfero::Plugin.new.send(event, *args)
-    result = default
     each do |plugin|
-      result = plugin.send(event, *args)
-      break if result != default
+      method = plugin.method event
+      next unless method.owner == plugin.class
+      return method.call(*args)
     end
-    result
+    Noosfero::Plugin.new.send event, *args
   end
 
   def fetch_first_plugin(event, *args)
-    default = Noosfero::Plugin.new.send(event, *args)
-    result = nil
+    default = Noosfero::Plugin.new.send event, *args
     each do |plugin|
-      if plugin.send(event, *args) != default
-        result = plugin.class
-        break
-      end
+      method = plugin.method event
+      next unless method.owner == plugin.class
+      next unless method.call(*args) != default
+      return plugin.class
     end
-    result
+    nil
   end
 
   def pipeline(event, *args)



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/48bfeb64b32d4dffdc6d2e45f972fc44d6db83ee

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/48bfeb64b32d4dffdc6d2e45f972fc44d6db83ee
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170520/edd314be/attachment-0001.html>


More information about the Noosfero-dev mailing list