class Rack::Mongoid

Constants

DEFAULT_MONGOID_CONFIGURATION_PATH
VERSION

Public Class Methods

call(env) click to toggle source
# File lib/rack/mongoid.rb, line 19
def call(env)
  configure_mongoid_unless_configured
  instance.call(env)
end
new(app = nil) click to toggle source
# File lib/rack/mongoid.rb, line 35
def initialize(app = nil)
  @app = app
end

Private Class Methods

configure_mongoid_unless_configured() click to toggle source
# File lib/rack/mongoid.rb, line 30
def configure_mongoid_unless_configured
  ::Mongoid.load!(DEFAULT_MONGOID_CONFIGURATION_PATH) unless ::Mongoid.configured?
end
instance() click to toggle source
# File lib/rack/mongoid.rb, line 26
def instance
  @instance ||= new
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/mongoid.rb, line 39
def call(env)
  router.call(env)
end

Private Instance Methods

router() click to toggle source
# File lib/rack/mongoid.rb, line 45
def router
  @router ||= Rack::Multiplexer.new(@app) do
    get "/:resource_name", Controllers::IndexController
    get "/:resource_name/:id", Controllers::ShowController
    post "/:resource_name", Controllers::CreateController
    patch "/:resource_name/:id", Controllers::UpdateController
    delete "/:resource_name/:id", Controllers::DestroyController
  end
end