Class: LaunchDarkly::Impl::BigSegmentStoreStatusProviderImpl

Inherits:
Object
  • Object
show all
Includes:
LaunchDarkly::Interfaces::BigSegmentStoreStatusProvider
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”.

Since:

  • 5.5.0

Instance Method Summary collapse

Constructor Details

#initialize(status_fn) ⇒ BigSegmentStoreStatusProviderImpl

Returns a new instance of BigSegmentStoreStatusProviderImpl.

Since:

  • 5.5.0



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

#statusObject

Since:

  • 5.5.0



104
105
106
# File 'lib/ldclient-rb/impl/big_segments.rb', line 104

def status
  @status_fn.call
end

#update_status(new_status) ⇒ Object

Since:

  • 5.5.0



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