class LittleGhost::Sandbox::EnvironmentPolicy
Declares whether a child inherits the host environment and which explicit values are added or replaced.
Attributes
Explicit child environment values.
Public Class Methods
Source
# File lib/little_ghost/sandbox/environment_policy.rb, line 9 def self.coerce(value) return value if value.is_a?(self) raise PolicyError, "sandbox environment must be a Hash" unless value.is_a?(Hash) if value.key?(:set) || value.key?("set") || value.key?(:inherit) || value.key?("inherit") values = value[:set] || value["set"] || {} inherit = value.fetch(:inherit, value.fetch("inherit", false)) else values = value inherit = false end new(inherit:, values:) end
Returns value unchanged or builds a policy from a Hash.
# File lib/little_ghost/sandbox/environment_policy.rb, line 24 def initialize(inherit: false, values: {}) raise PolicyError, "sandbox environment values must be a Hash" unless values.is_a?(Hash) @inherit = !!inherit @values = values.to_h { |key, value| [String(key).freeze, String(value).freeze] }.freeze freeze end
Builds an environment policy with explicit String-compatible values.
Public Instance Methods
Source
# File lib/little_ghost/sandbox/environment_policy.rb, line 36 def inherit? = @inherit
Indicates whether configured backends may inherit host values.
Source
# File lib/little_ghost/sandbox/environment_policy.rb, line 38 def to_h = values
Returns the explicit child environment values.