Skip to content

Instantly share code, notes, and snippets.

@ugisozols
Created November 22, 2012 19:14
Show Gist options
  • Save ugisozols/4132588 to your computer and use it in GitHub Desktop.
Save ugisozols/4132588 to your computer and use it in GitHub Desktop.
Don't depend on Rails' delegate
diff --git a/core/lib/refinery/plugins.rb b/core/lib/refinery/plugins.rb
index 7f7efea..869286a 100644
--- a/core/lib/refinery/plugins.rb
+++ b/core/lib/refinery/plugins.rb
@@ -1,11 +1,16 @@
+require 'forwardable'
+
module Refinery
class Plugins
include Enumerable
+ extend Forwardable
def initialize(*args)
@plugins = Array.new(*args)
end
+ def_delegators :@plugins, :<<, :each, :delete_if
+
def find_by_model(model)
model = model.constantize if model.is_a? String
detect { |plugin| plugin.activity.any? {|activity| activity.klass == model } }
@@ -36,8 +41,6 @@ module Refinery
map(&:title)
end
- delegate :<<, :delete_if, :each, :to => :plugins
-
class << self
def active
@active_plugins ||= new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment