Class: FancyCount::TestAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/fancy_count/test_adapter.rb

Constant Summary collapse

@@counts =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config) ⇒ TestAdapter

Returns a new instance of TestAdapter.



19
20
21
22
23
# File 'lib/fancy_count/test_adapter.rb', line 19

def initialize(name, config)
  super(name, config)
  self.class.counts ||= {}
  self.class.counts[name] ||= 0
end

Class Method Details

.countsObject



11
12
13
# File 'lib/fancy_count/test_adapter.rb', line 11

def self.counts
  @@counts
end

.counts=(value) ⇒ Object



15
16
17
# File 'lib/fancy_count/test_adapter.rb', line 15

def self.counts=(value)
  @@counts = value
end

.resetObject



7
8
9
# File 'lib/fancy_count/test_adapter.rb', line 7

def self.reset
  self.counts = {}
end

Instance Method Details

#change(value) ⇒ Object



33
34
35
# File 'lib/fancy_count/test_adapter.rb', line 33

def change(value)
  self.class.counts[@name] = value
end

#decrementObject



29
30
31
# File 'lib/fancy_count/test_adapter.rb', line 29

def decrement
  self.class.counts[@name] -= 1
end

#deleteObject



45
46
47
# File 'lib/fancy_count/test_adapter.rb', line 45

def delete
  self.class.counts.delete(@name)
end

#incrementObject



25
26
27
# File 'lib/fancy_count/test_adapter.rb', line 25

def increment
  self.class.counts[@name] += 1
end

#resetObject



37
38
39
# File 'lib/fancy_count/test_adapter.rb', line 37

def reset
  self.class.counts[@name] = 0
end

#valueObject



41
42
43
# File 'lib/fancy_count/test_adapter.rb', line 41

def value
  self.class.counts[@name]
end