Class: Grape::Attack::Adapters::Memory
- Inherits:
-
Object
- Object
- Grape::Attack::Adapters::Memory
- Defined in:
- lib/grape/attack/adapters/memory.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #atomically(&block) ⇒ Object
- #expire(key, ttl_in_seconds) ⇒ Object
- #get(key) ⇒ Object
- #incr(key) ⇒ Object
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
8 9 10 |
# File 'lib/grape/attack/adapters/memory.rb', line 8 def initialize @data = {} end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/grape/attack/adapters/memory.rb', line 6 def data @data end |
Instance Method Details
#atomically(&block) ⇒ Object
24 25 26 |
# File 'lib/grape/attack/adapters/memory.rb', line 24 def atomically(&block) block.call end |
#expire(key, ttl_in_seconds) ⇒ Object
21 22 |
# File 'lib/grape/attack/adapters/memory.rb', line 21 def expire(key, ttl_in_seconds) end |
#get(key) ⇒ Object
12 13 14 |
# File 'lib/grape/attack/adapters/memory.rb', line 12 def get(key) data[key] end |
#incr(key) ⇒ Object
16 17 18 19 |
# File 'lib/grape/attack/adapters/memory.rb', line 16 def incr(key) data[key] ||= 0 data[key] += 1 end |