Class: FeatureHub::Sdk::ServerEvalFeatureContext

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

Overview

context used when evaluating server side

Instance Attribute Summary

Attributes inherited from ClientContext

#repo

Instance Method Summary collapse

Methods inherited from ClientContext

#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.



164
165
166
167
168
169
# File 'lib/feature_hub/sdk/context.rb', line 164

def initialize(repo, edge)
  super(repo)

  @edge = edge
  @old_header = nil
end

Instance Method Details

#buildObject



171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/feature_hub/sdk/context.rb', line 171

def build
  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



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

def build_sync
  build
end