Class: SolidCache::Connections::Single

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_cache/connections/single.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Single

Returns a new instance of Single.



6
7
8
# File 'lib/solid_cache/connections/single.rb', line 6

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/solid_cache/connections/single.rb', line 4

def name
  @name
end

Instance Method Details

#assign(keys) ⇒ Object



24
25
26
# File 'lib/solid_cache/connections/single.rb', line 24

def assign(keys)
  { name => keys }
end

#countObject



28
29
30
# File 'lib/solid_cache/connections/single.rb', line 28

def count
  1
end

#namesObject



32
33
34
# File 'lib/solid_cache/connections/single.rb', line 32

def names
  [ name ]
end

#with(name, &block) ⇒ Object



16
17
18
# File 'lib/solid_cache/connections/single.rb', line 16

def with(name, &block)
  Record.with_shard(name, &block)
end

#with_connection_for(key, &block) ⇒ Object



20
21
22
# File 'lib/solid_cache/connections/single.rb', line 20

def with_connection_for(key, &block)
  with(name, &block)
end

#with_each(&block) ⇒ Object



10
11
12
13
14
# File 'lib/solid_cache/connections/single.rb', line 10

def with_each(&block)
  return enum_for(:with_each) unless block_given?

  with(name, &block)
end