Sha256: 0c8d1316c6dea0f06c4759780c7e180c64bbd253431b91a818046762ba54c83e

Contents?: true

Size: 612 Bytes

Versions: 1

Compression:

Stored size: 612 Bytes

Contents

module Observed
  module Pluggable

    module ClassMethods
      def plugins
        @plugins ||= []
      end

      def inherited(klass)
        plugins << klass
      end

      def plugin_name(plugin_name=nil)
        @plugin_name = plugin_name if plugin_name
        @plugin_name
      end

      def find_plugin_named(plugin_name)
        plugins.find { |plugin| plugin.plugin_name == plugin_name }
      end

      def select_named_plugins
        plugins.select(&:plugin_name)
      end
    end

    class << self
      def included(klass)
        klass.extend ClassMethods
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
observed-0.1.1 lib/observed/pluggable.rb