class LittleGhost::Sandbox::EnvironmentPolicy
Declares which environment values a Sandbox may pass to child processes.
A Policy supplies a scrubbed locale and path baseline when its environment option is omitted. Declaring an EnvironmentPolicy replaces that baseline. Workspace routing variables are added separately. Enabling inheritance here only permits it; an individual process call must also opt in.
See the Workspaces and Sandboxes guide for defaults and host-path considerations.
Attributes
Explicit child environment values, before Workspace routing values are added.
Public Class Methods
Source
# File lib/little_ghost/sandbox/environment_policy.rb, line 34 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 49 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 61 def inherit? = @inherit
Indicates whether a process call may opt into inheriting host values.
Source
# File lib/little_ghost/sandbox/environment_policy.rb, line 63 def to_h = values
Returns the explicit child environment values.