Class: Ruptr::GoldenMaster::Store
- Inherits:
-
Object
- Object
- Ruptr::GoldenMaster::Store
- Defined in:
- lib/ruptr/golden_master.rb
Direct Known Subclasses
Defined Under Namespace
Classes: FS
Instance Method Summary collapse
- #accept_trial(preserve: nil) ⇒ Object
- #flush_trial ⇒ Object
- #get_golden(k) ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #set_trial(k, v) ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
70 71 72 73 |
# File 'lib/ruptr/golden_master.rb', line 70 def initialize @golden = {} @trial = {} end |
Instance Method Details
#accept_trial(preserve: nil) ⇒ Object
86 87 88 89 90 |
# File 'lib/ruptr/golden_master.rb', line 86 def accept_trial(preserve: nil) @golden.each_pair { |k, v| @trial[k] = v if !@trial.include?(k) && preserve.call(k) } if preserve @golden = @trial @trial = {} end |
#flush_trial ⇒ Object
84 |
# File 'lib/ruptr/golden_master.rb', line 84 def flush_trial = nil |
#get_golden(k) ⇒ Object
75 76 77 |
# File 'lib/ruptr/golden_master.rb', line 75 def get_golden(k, &) @golden.fetch(k, &) end |
#set_trial(k, v) ⇒ Object
79 80 81 82 |
# File 'lib/ruptr/golden_master.rb', line 79 def set_trial(k, v) raise ArgumentError, "key already used: #{k.inspect}" if @trial.include?(k) @trial.store(k, v) end |