Sha256: 8281ca5e73b0673a987eeb8ab0ebe000a3680234ea2fc2dbc29f8e2f9498acbf

Contents?: true

Size: 858 Bytes

Versions: 9

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

module Flagsmith
  module Engine
    # ProjectModel
    class Project
      attr_reader :id, :name, :organisation
      attr_accessor :segments, :hide_disabled_flags

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

      class << self
        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
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
flagsmith-4.3.0 lib/flagsmith/engine/projects/models.rb
flagsmith-4.1.0 lib/flagsmith/engine/projects/models.rb
flagsmith-4.0.1 lib/flagsmith/engine/projects/models.rb
flagsmith-4.0.0 lib/flagsmith/engine/projects/models.rb
flagsmith-3.2.0 lib/flagsmith/engine/projects/models.rb
flagsmith-3.1.1 lib/flagsmith/engine/projects/models.rb
flagsmith-3.1.0 lib/flagsmith/engine/projects/models.rb
flagsmith-3.0.1 lib/flagsmith/engine/projects/models.rb
flagsmith-3.0.0 lib/flagsmith/engine/projects/models.rb