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

Version Path
mongo_mapper-0.16.0 examples/plugins.rb
mongo_mapper-0.15.6 examples/plugins.rb
mongo_mapper-0.15.5 examples/plugins.rb
mongo_mapper-0.15.4 examples/plugins.rb
mongo_mapper-0.15.3 examples/plugins.rb
mongo_mapper-0.15.2 examples/plugins.rb
mongo_mapper-0.15.1 examples/plugins.rb
mongo_mapper-0.15.0 examples/plugins.rb
mongo_mapper-0.14.0 examples/plugins.rb
mongo_mapper-0.14.0.rc1 examples/plugins.rb
mongo_mapper-0.13.1 examples/plugins.rb
mongo_mapper-0.13.0 examples/plugins.rb
mongo_mapper-0.13.0.beta2 examples/plugins.rb
mongo_mapper-0.13.0.beta1 examples/plugins.rb
mongo_mapper-0.12.0 examples/plugins.rb
lookout-mongo_mapper-0.11.3 examples/plugins.rb
mongo_mapper-0.11.2 examples/plugins.rb
jamieorc-mongo_mapper-0.11.1.1 examples/plugins.rb
mongo_mapper-0.11.1 examples/plugins.rb
mongo_mapper-0.11.0 examples/plugins.rb