Module: MongoMapper::Document

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

DUMP_ATTRS =

include ActiveModel::Serialization

[:@attributes]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.redisRedis

Getter for redis object

Returns:

  • (Redis)

    redis cache instance



23
24
25
# File 'lib/octocore-mongo/models.rb', line 23

def self.redis
  @redis
end

.update_cache_config(host, port) ⇒ Object

Updates caching config

Parameters:

  • host (String)

    The host to connect to

  • port (Fixnum)

    The port to connect to



15
16
17
18
19
# File 'lib/octocore-mongo/models.rb', line 15

def self.update_cache_config(host, port)
  @redis = Redis.new(host: host,
                     port: port,
                     driver: :hiredis)
end

Instance Method Details

#marshal_dumpObject



27
28
29
30
31
32
# File 'lib/octocore-mongo/models.rb', line 27

def marshal_dump
  DUMP_ATTRS.inject({}) do |val, attr|
    val[attr] = self.instance_variable_get(attr)
    val
  end
end

#marshal_load(data) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/octocore-mongo/models.rb', line 34

def marshal_load(data)
  DUMP_ATTRS.each do |attr|
    instance_variable_set(attr, data[attr])
  end
  instance_variable_set(:@collection_proxies, {})
  instance_variable_set(:@record_collection, nil)
end