classx-pluggable

plagger’s like plugin system for classx based applicaton

Synopsis

in your context class.

require 'classx'
require 'classx/pluggable'
class YourApp
  include ClassX
  include ClassX::Pluggable

  def run
    call_event("SETUP", {})
    # you app
    call_event("TEARDOWN", {})
  end
end

in your plugin class

require 'classx'
require 'classx/pluggable'
class YourApp
  class Plugin
    include ClassX
    include ClassX::Pluggable::Plugin

    class SomePlugin < Plugin
      def register
        add_event("SETUP", :on_setup)
      end

      def on_setup param
        # param is Hash
        # hooked setup
      end
    end
  end
end

or it’s easy to defining with ClassX::Pluggable::Plugin::AutoRegister

class YourApp
  class Plugin
    include ClassX
    include ClassX::Pluggable::Plugin
    include ClassX::Pluggable::Plugin::AutoRegister

    class SomePlugin < Plugin
      def on_setup param
        # do some thing.
      end
    end
  end
end

and, on your start up script.

app = YourApp.new
app.load_plugins([
  { :module => YourApp::Plugin::SomePlugin, :config => {} },
])

app.run

Description

Installation

Archive Installation

rake install

Gem Installation

Features/Problems

CAVEAT: this project is early development. API may be vary in future.

Author

Keiji, Yoshimi <walf443 at gmail.com>

Copyright

Copyright © 2008 Keiji, Yoshimi

License

you can redistribute it and/or modify it under the same terms as Ruby itself.