Sha256: fa075cae7ec4a8bde2a78e1499f362e6d30939b3bf931c81dfd8a88b78a11ae7

Contents?: true

Size: 681 Bytes

Versions: 6

Compression:

Stored size: 681 Bytes

Contents

module Netzke
  module Plugins
    extend ActiveSupport::Concern

    module ClassMethods
      # Defines a plugin
      def plugin(name, config = {}, &block)
        component(name, config, &block)
        register_plugin(name)
      end

      # Register a plugin
      def register_plugin(name)
        current_plugins = read_inheritable_attribute(:plugins) || []
        current_plugins << name
        write_inheritable_attribute(:plugins, current_plugins.uniq)
      end

      # Returns registered plugins
      def registered_plugins
        read_inheritable_attribute(:plugins) || []
      end
    end

    def plugins
      self.class.registered_plugins
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
netzke-core-0.7.5 lib/netzke/plugins.rb
netzke-core-0.7.4 lib/netzke/plugins.rb
netzke-core-0.7.3 lib/netzke/plugins.rb
netzke-core-0.7.2 lib/netzke/plugins.rb
netzke-core-0.7.1 lib/netzke/plugins.rb
netzke-core-0.7.0 lib/netzke/plugins.rb