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: []) ⇒ Environment

Returns a new instance of Environment.



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

def initialize(id:, api_key:, project:, feature_states: [])
  @id = id
  @api_key = api_key
  @project = project
  @feature_states = feature_states
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

#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



19
20
21
22
23
24
25
26
# File 'lib/flagsmith/engine/environments/models.rb', line 19

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

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