Module: Ohm

Defined in:
lib/ohm/version.rb,
lib/ohm.rb,
lib/ohm/key.rb,
lib/ohm/collection.rb,
lib/ohm/validations.rb,
lib/ohm/compat-1.8.6.rb,
lib/ohm/utils/upgrade.rb

Overview

encoding: UTF-8

Defined Under Namespace

Modules: Utils, Validations Classes: Collection, Key, List, Model, Set

Constant Summary

Error =
Class.new(StandardError)
VERSION =
"0.1.0.rc2"
BasicObject =
BasicObject

Instance Method Summary (collapse)

Instance Method Details

- (Object) connect(*options)

Connect to a redis database.

Examples:

Connect to a database in port 6380.

Ohm.connect(:port => 6380)

Parameters:

  • (Hash) options

    options to create a message with.



35
36
37
38
# File 'lib/ohm.rb', line 35

def connect(*options)
  self.redis = nil
  @options = options
end

- (Object) connection(*options)

Return a connection to Redis.

This is a wapper around Redis.new(options)



43
44
45
# File 'lib/ohm.rb', line 43

def connection(*options)
  Redis.new(*options)
end

- (Object) flush

Clear the database.



52
53
54
# File 'lib/ohm.rb', line 52

def flush
  redis.flushdb
end

- (Object) key(*args)



56
57
58
# File 'lib/ohm.rb', line 56

def key(*args)
  Key[*args]
end

- (Object) options



47
48
49
# File 'lib/ohm.rb', line 47

def options
  @options || []
end

- (Object) redis

Provides access to the Redis database. This is shared accross all models and instances.



14
15
16
# File 'lib/ohm.rb', line 14

def redis
  threaded[:redis] ||= connection(*options)
end

- (Object) redis=(connection)



18
19
20
# File 'lib/ohm.rb', line 18

def redis=(connection)
  threaded[:redis] = connection
end

- (Object) threaded



22
23
24
# File 'lib/ohm.rb', line 22

def threaded
  Thread.current[:ohm] ||= {}
end