Class: Flagsmith::Engine::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/flagsmith/engine/environments/models.rb

Overview

EnvironmentModel

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, api_key:, project:, feature_states: [], identity_overrides: []) ⇒ Environment

Returns a new instance of Environment.



11
12
13
14
15
16
17
# File 'lib/flagsmith/engine/environments/models.rb', line 11

def initialize(id:, api_key:, project:, feature_states: [], identity_overrides: [])
  @id = id
  @api_key = api_key
  @project = project
  @feature_states = feature_states
  @identity_overrides = identity_overrides
end

Instance Attribute Details

#amplitude_configObject

Returns the value of attribute amplitude_config.



8
9
10
# File 'lib/flagsmith/engine/environments/models.rb', line 8

def amplitude_config
  @amplitude_config
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



7
8
9
# File 'lib/flagsmith/engine/environments/models.rb', line 7

def api_key
  @api_key
end

#feature_statesObject

Returns the value of attribute feature_states.



8
9
10
# File 'lib/flagsmith/engine/environments/models.rb', line 8

def feature_states
  @feature_states
end

#heap_configObject

Returns the value of attribute heap_config.



8
9
10
# File 'lib/flagsmith/engine/environments/models.rb', line 8

def heap_config
  @heap_config
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/flagsmith/engine/environments/models.rb', line 7

def id
  @id
end

#identity_overridesObject

Returns the value of attribute identity_overrides.



8
9
10
# File 'lib/flagsmith/engine/environments/models.rb', line 8

def identity_overrides
  @identity_overrides
end

#mixpanel_configObject

Returns the value of attribute mixpanel_config.



8
9
10
# File 'lib/flagsmith/engine/environments/models.rb', line 8

def mixpanel_config
  @mixpanel_config
end

#projectObject

Returns the value of attribute project.



8
9
10
# File 'lib/flagsmith/engine/environments/models.rb', line 8

def project
  @project
end

#segment_configObject

Returns the value of attribute segment_config.



8
9
10
# File 'lib/flagsmith/engine/environments/models.rb', line 8

def segment_config
  @segment_config
end

Class Method Details

.build(json) ⇒ Object

rubocop:disable Metrics/MethodLength



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/flagsmith/engine/environments/models.rb', line 21

def build(json)
  project = Flagsmith::Engine::Project.build(json[:project])
  feature_states = json[:feature_states].map do |fs|
    Flagsmith::Engine::FeatureState.build(fs)
  end

  identity_overrides = json.fetch(:identity_overrides, []).map do |io|
    Flagsmith::Engine::Identity.build(io)
  end

  new(**json.slice(:id, :api_key).merge(
    project: project,
    feature_states: feature_states,
    identity_overrides: identity_overrides
  ))
end