Class: LaunchDarkly::Impl::FlagTracker::FlagValueChangeAdapter Private
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::FlagTracker::FlagValueChangeAdapter
- Defined in:
- lib/ldclient-rb/impl/flag_tracker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
An adapter which turns a normal flag change listener into a flag value change listener.
Instance Method Summary collapse
-
#initialize(flag_key, context, listener, eval_fn) ⇒ FlagValueChangeAdapter
constructor
private
A new instance of FlagValueChangeAdapter.
- #update(flag_change) ⇒ Object private
Constructor Details
#initialize(flag_key, context, listener, eval_fn) ⇒ FlagValueChangeAdapter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of FlagValueChangeAdapter.
33 34 35 36 37 38 39 |
# File 'lib/ldclient-rb/impl/flag_tracker.rb', line 33 def initialize(flag_key, context, listener, eval_fn) @flag_key = flag_key @context = context @listener = listener @eval_fn = eval_fn @value = Concurrent::AtomicReference.new(@eval_fn.call(@flag_key, @context)) end |
Instance Method Details
#update(flag_change) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ldclient-rb/impl/flag_tracker.rb', line 44 def update(flag_change) return unless flag_change.key == @flag_key new_eval = @eval_fn.call(@flag_key, @context) old_eval = @value.get_and_set(new_eval) return if new_eval == old_eval @listener.update( LaunchDarkly::Interfaces::FlagValueChange.new(@flag_key, old_eval, new_eval)) end |