Class: FancyCount::TestAdapter
- Defined in:
- lib/fancy_count/test_adapter.rb
Constant Summary collapse
- @@counts =
{}
Class Method Summary collapse
Instance Method Summary collapse
- #change(value) ⇒ Object
- #decrement ⇒ Object
- #delete ⇒ Object
- #increment ⇒ Object
-
#initialize(name, config) ⇒ TestAdapter
constructor
A new instance of TestAdapter.
- #reset ⇒ Object
- #value ⇒ Object
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
.counts ⇒ Object
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 |
.reset ⇒ Object
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 |
#decrement ⇒ Object
29 30 31 |
# File 'lib/fancy_count/test_adapter.rb', line 29 def decrement self.class.counts[@name] -= 1 end |
#delete ⇒ Object
45 46 47 |
# File 'lib/fancy_count/test_adapter.rb', line 45 def delete self.class.counts.delete(@name) end |
#increment ⇒ Object
25 26 27 |
# File 'lib/fancy_count/test_adapter.rb', line 25 def increment self.class.counts[@name] += 1 end |
#reset ⇒ Object
37 38 39 |
# File 'lib/fancy_count/test_adapter.rb', line 37 def reset self.class.counts[@name] = 0 end |
#value ⇒ Object
41 42 43 |
# File 'lib/fancy_count/test_adapter.rb', line 41 def value self.class.counts[@name] end |