Class: Flagsmith::Engine::Project

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

Overview

ProjectModel

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, organisation:, hide_disabled_flags:, segments: []) ⇒ Project

Returns a new instance of Project.



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

def initialize(id:, name:, organisation:, hide_disabled_flags:, segments: [])
  @id = id
  @name = name
  @hide_disabled_flags = hide_disabled_flags
  @organisation = organisation
  @segments = segments
end

Instance Attribute Details

#hide_disabled_flagsObject

Returns the value of attribute hide_disabled_flags.



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

def hide_disabled_flags
  @hide_disabled_flags
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#organisationObject (readonly)

Returns the value of attribute organisation.



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

def organisation
  @organisation
end

#segmentsObject

Returns the value of attribute segments.



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

def segments
  @segments
end

Class Method Details

.build(json) ⇒ Object



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

def build(json)
  segments = json.fetch(:segments, []).map { |s| Flagsmith::Engine::Segment.build(s) }

  new(
    **json.slice(:id, :name, :hide_disabled_flags)
          .merge(organisation: Flagsmith::Engine::Organisation.build(json[:organisation]))
          .merge(segments: segments)
  )
end