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.



8
9
10
# File 'lib/solid_cache/connections/single.rb', line 8

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#assign(keys) ⇒ Object



26
27
28
# File 'lib/solid_cache/connections/single.rb', line 26

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

#countObject



30
31
32
# File 'lib/solid_cache/connections/single.rb', line 30

def count
  1
end

#namesObject



34
35
36
# File 'lib/solid_cache/connections/single.rb', line 34

def names
  [ name ]
end

#with(name, &block) ⇒ Object



18
19
20
# File 'lib/solid_cache/connections/single.rb', line 18

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

#with_connection_for(key, &block) ⇒ Object



22
23
24
# File 'lib/solid_cache/connections/single.rb', line 22

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

#with_each(&block) ⇒ Object



12
13
14
15
16
# File 'lib/solid_cache/connections/single.rb', line 12

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

  with(name, &block)
end