Class: LaunchDarkly::Impl::BigSegmentStoreStatusProviderImpl
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::BigSegmentStoreStatusProviderImpl
- Defined in:
- lib/ldclient-rb/impl/big_segments.rb
Overview
Default implementation of the BigSegmentStoreStatusProvider interface.
There isn’t much to this because the real implementation is in BigSegmentStoreManager - we pass in a lambda that allows us to get the current status from that class. Also, the standard Observer methods such as add_observer are provided for us because BigSegmentStoreStatusProvider mixes in Observer, so all we need to to do make notifications happen is to call the Observer methods “changed” and “notify_observers”.
Instance Method Summary collapse
-
#initialize(status_fn) ⇒ BigSegmentStoreStatusProviderImpl
constructor
A new instance of BigSegmentStoreStatusProviderImpl.
- #status ⇒ Object
- #update_status(new_status) ⇒ Object
Constructor Details
#initialize(status_fn) ⇒ BigSegmentStoreStatusProviderImpl
Returns a new instance of BigSegmentStoreStatusProviderImpl.
99 100 101 102 |
# File 'lib/ldclient-rb/impl/big_segments.rb', line 99 def initialize(status_fn) @status_fn = status_fn @last_status = nil end |
Instance Method Details
#status ⇒ Object
104 105 106 |
# File 'lib/ldclient-rb/impl/big_segments.rb', line 104 def status @status_fn.call end |
#update_status(new_status) ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/ldclient-rb/impl/big_segments.rb', line 108 def update_status(new_status) if !@last_status || new_status != @last_status @last_status = new_status changed notify_observers(new_status) end end |