Sha256: c57190e8c452dd77b146f25c343a17b28d948d2034ef393e8081161522247cb6

Contents?: true

Size: 1.08 KB

Versions: 16

Compression:

Stored size: 1.08 KB

Contents

module Refinery
  class Plugins < Array
  
    def initialize
      @plugins = []
    end

    def find_by_title(title)
      self.reject { |plugin| plugin.title != title }.first
    end

    def find_by_model(model)
      self.reject { |plugin| plugin.activity.reject {|activity| activity.class != model }.empty? }.first
    end

    def find_activity_by_model(model)
      plugin = find_by_model(model)
      plugin.activity.reject {|activity| activity.class != model}.first unless plugin.nil?
    end

    def [](title)
      self.find { |plugin| plugin.title == title }
    end

    def self.registered
      @registered_plugins ||= self.new
    end

    def titles
      self.collect { |p| p.title }
    end

    def in_menu
      self.reject{ |p| p.hide_from_menu }
    end

    def self.active
      @active_plugins ||= self.new
    end

    def self.always_allowed
      registered.reject { |p| !p.always_allow_access }
    end

    def self.set_active(titles)
      active.clear
      titles.each do |title|
        active << registered[title] if registered[title]
      end
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
refinerycms-0.9.5.13 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.12 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.11 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.10 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.9 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.8 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.7 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.6 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.5 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.4 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.3 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.2 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5.1 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.5 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.4.5 vendor/plugins/refinery/lib/refinery/plugins.rb
refinerycms-0.9.4.4 vendor/plugins/refinery/lib/refinery/plugins.rb