Sha256: 0730a165285c66b56c4d62d39e4e5b6cb518c55f8bb5e79e0bb07e29a779e6b2
Contents?: true
Size: 785 Bytes
Versions: 20
Compression:
Stored size: 785 Bytes
Contents
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__)) require 'mongo_mapper' require 'pp' MongoMapper.database = 'testing' # To create your own plugin, just create a module that # extends ActiveSupport::Concern. module FooPlugin extend ActiveSupport::Concern # ClassMethods module will automatically get extended module ClassMethods def foo 'Foo class method!' end end def foo 'Foo instance method!' end # Any configuration can be done in the #included block, which gets # class evaled. Feel free to add keys, validations, or anything else. included do puts "Configuring #{self}..." key :foo, String end end class User include MongoMapper::Document plugin FooPlugin end puts User.foo puts User.new.foo puts User.key?(:foo)
Version data entries
20 entries across 20 versions & 3 rubygems