Module: Sinatra::Monk

Defined in:
lib/sinatra-monk/2.0.rb,
lib/sinatra-monk/monk.rb,
lib/sinatra-monk/helpers.rb

Defined Under Namespace

Classes: MBase, MHash

Instance Method Summary collapse

Instance Method Details

#hmonk(name = 'monk', user = '', pass = '', database = 'local', host = 'localhost', port = 27017, opts = {:save => true}) ⇒ MHash

(Any Ruby) A helper that create a MHash instance.

Parameters:

  • name (String) (defaults to: 'monk')

    name of the used/created collection,

  • user (String) (defaults to: '')

    the database username,

  • pass (String) (defaults to: '')

    the password of the previous database user,

  • database (String) (defaults to: 'local')

    the name of the database,

  • host (String) (defaults to: 'localhost')

    the host of the database,

  • port (Fixnum) (defaults to: 27017)

    the port to connect to the database,

  • opts (Hash) (defaults to: {:save => true})

    monk options (set :save to autosave after each change)

Returns:

  • (MHash)

    the Monk instance.



94
95
96
97
# File 'lib/sinatra-monk/2.0.rb', line 94

def hmonk(name:'monk', user:'', pass:'', database:'local', host:'localhost',
          port:27017, opts:{:connect => false})
  return MHash.new(name, user, pass, database, host, port, opts)
end

#monk(user = '', pass = '', database = 'local', host = 'localhost', port = 27017, opts = {:connect => false}) ⇒ MBase

(Any Ruby) A helper that create a MBase instance.

Parameters:

  • user (String) (defaults to: '')

    the database username,

  • pass (String) (defaults to: '')

    the password of the previous database user,

  • database (String) (defaults to: 'local')

    the name of the database,

  • host (String) (defaults to: 'localhost')

    the host of the database,

  • port (Fixnum) (defaults to: 27017)

    the port to connect to the database,

  • opts (Hash) (defaults to: {:connect => false})

    monk options (set :conect to autoconnect the Monk)

Returns:

  • (MBase)

    the Monk instance.



80
81
82
83
# File 'lib/sinatra-monk/2.0.rb', line 80

def monk(user:'', pass:'', database:'local', host:'localhost',
         port:27017, opts:{:connect => false})
  return MBase.new(user, pass, database, host, port, opts)
end