Class: FeatureHub::Sdk::ServerEvalFeatureContext

Inherits:
ClientContext show all
Defined in:
lib/feature_hub/sdk/context.rb

Overview

context used when evaluating server side

Constant Summary

Constants inherited from ClientContext

ClientContext::WELL_KNOWN_KEY_METHODS

Instance Attribute Summary

Attributes inherited from ClientContext

#repo

Instance Method Summary collapse

Methods inherited from ClientContext

#assign, #attribute_value, #boolean, #clear, #country, #default_percentage_key, #device, #enabled?, #exists?, #feature, #flag, #get_attr, #json, #number, #platform, #raw_json, #session_key, #set?, #string, #user_key, #version

Constructor Details

#initialize(repo, edge) ⇒ ServerEvalFeatureContext

Returns a new instance of ServerEvalFeatureContext.



185
186
187
188
189
190
# File 'lib/feature_hub/sdk/context.rb', line 185

def initialize(repo, edge)
  super(repo)

  @edge = edge
  @old_header = nil
end

Instance Method Details

#buildObject



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/feature_hub/sdk/context.rb', line 192

def build
  return self unless @edge

  new_header = @attributes.map { |k, v| "#{k}=#{URI.encode_www_form_component(v[0].to_s)}" } * "&"

  if @old_header.nil? && new_header.empty?
    @edge.poll
  elsif new_header != @old_header
    @old_header = new_header
    @repo.not_ready!

    @edge.context_change(new_header)
  end

  self
end

#build_syncObject



209
210
211
# File 'lib/feature_hub/sdk/context.rb', line 209

def build_sync
  build
end