Sha256: 62d2240a41eddea9950ae3c8d70db3fbf8bfb6548f8ee7ae78b6f902c6a116fc

Contents?: true

Size: 1.15 KB

Versions: 12

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require_relative 'validation'
require_relative '../../model'

module Lino
  module Builders
    module Mixins
      module EnvironmentVariables
        include Validation

        def initialize(state)
          @environment_variables =
            Hamster::Vector.new(state[:environment_variables] || [])
          super
        end

        def with_environment_variable(environment_variable, value)
          with(
            environment_variables:
              @environment_variables.add(
                Model::EnvironmentVariable.new(environment_variable, value)
              )
          )
        end

        def with_environment_variables(environment_variables)
          return self if nil_or_empty?(environment_variables)

          environment_variables.entries.inject(self) do |s, var|
            s.with_environment_variable(
              var.include?(:name) ? var[:name] : var[0],
              var.include?(:value) ? var[:value] : var[1]
            )
          end
        end

        private

        def state
          super.merge(environment_variables: @environment_variables)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
lino-4.2.0.pre.2 lib/lino/builders/mixins/environment_variables.rb
lino-4.2.0.pre.1 lib/lino/builders/mixins/environment_variables.rb
lino-4.1.0 lib/lino/builders/mixins/environment_variables.rb
lino-4.1.0.pre.2 lib/lino/builders/mixins/environment_variables.rb
lino-4.1.0.pre.1 lib/lino/builders/mixins/environment_variables.rb
lino-4.0.0 lib/lino/builders/mixins/environment_variables.rb
lino-4.0.0.pre.2 lib/lino/builders/mixins/environment_variables.rb
lino-3.2.0.pre.10 lib/lino/builders/mixins/environment_variables.rb
lino-3.2.0.pre.9 lib/lino/builders/mixins/environment_variables.rb
lino-3.2.0.pre.8 lib/lino/builders/mixins/environment_variables.rb
lino-3.2.0.pre.7 lib/lino/builders/mixins/environment_variables.rb
lino-3.2.0.pre.6 lib/lino/builders/mixins/environment_variables.rb