Class: Downgrade::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/downgrade/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid) ⇒ Block

Returns a new instance of Block.



4
5
6
# File 'lib/downgrade/block.rb', line 4

def initialize(uuid)
  @uuid = uuid
end

Instance Attribute Details

#uuidObject

Returns the value of attribute uuid.



3
4
5
# File 'lib/downgrade/block.rb', line 3

def uuid
  @uuid
end

Instance Method Details

#cacheObject



8
9
10
11
12
13
14
15
16
# File 'lib/downgrade/block.rb', line 8

def cache
  if Downgrade.block_switch.is_on?
    Downgrade.cache_store.fetch(cache_key, expires_in: 10.minutes) do
      yield
    end
  else
    yield
  end
end

#cache_keyObject



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

def cache_key
  "downgrade:block:#{uuid}"
end