0.0
No commit activity in last 3 years
No release in over 3 years
Easily add and configure plugins for Mongoid
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 4.3.2
>= 0.1.12
~> 2.0

Runtime

>= 2.0.0.beta.20
 Project Readme

mongoid-plugins¶ ↑

Easily add and configure plugins for Mongoid

Requirements¶ ↑

  • mongoid (>= 2.0.0.beta.20)

Install¶ ↑

To install mongoid-plugins, simply add it to your Gemfile:

gem 'mongoid-plugins', :require => 'mongoid/plugins'

In order to get the latest development version of mongoid-plugins:

gem 'mongoid-plugins', :git => 'git://github.com/benedikt/mongoid-plugins', :require => 'mongoid/plugins'

You might want to remove the :require => 'mongoid/plugins' option and explicitly require 'mongoid/plugins' where needed and finally run

bundle install

Usage¶ ↑

class SomeDocument
  include Mongoid::Document

  plugin SomePlugin do |c|
    c.some_setting = false
  end
end

Writing Plugins¶ ↑

It’s fairly easy to write plugins compatible with Mongoid::Plugins. In fact they’re simply Ruby modules. It’s possible to add default options by defining a default_plugin_options method on your module returning a hash:

module SomePlugin
  def self.default_plugin_options
    {
      :some_default_setting => 100
    }
  end
end

To access the options from within your plugin just call plugin_options_for(SomePlugin):

module SomePlugin
  def a_plugin_method
    if self.plugin_options_for(SomePlugin).do_something
      # Do something :-)
    end
  end
end

Known issues¶ ↑

See github.com/benedikt/mongoid-plugins/issues

Repository¶ ↑

See github.com/benedikt/mongoid-plugins and feel free to fork it!

Copyright © 2010 Benedikt Deicke. See LICENSE for details.