Class: LittleGhost::Sandbox::IsolatedBackend

Inherits:
Sandbox
  • Object
show all
Defined in:
lib/little_ghost/sandbox/isolated_backend.rb

Overview

Shared policy and filesystem behavior for enforcing backends.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workspace:, policy: nil, profiles: {}, limits: {}) ⇒ IsolatedBackend

:nodoc:



11
12
13
14
# File 'lib/little_ghost/sandbox/isolated_backend.rb', line 11

def initialize(workspace:, policy: nil, profiles: {}, limits: {})
  super
  @effective_policy = policy_with_network_default(self.policy)
end

Instance Attribute Details

#effective_policyObject (readonly)

Returns the value of attribute effective_policy.



16
17
18
# File 'lib/little_ghost/sandbox/isolated_backend.rb', line 16

def effective_policy
  @effective_policy
end

Instance Method Details

#list(path = ".", context: nil) ⇒ Object



23
# File 'lib/little_ghost/sandbox/isolated_backend.rb', line 23

def list(path = ".", context: nil) = default_scope.list(path, context:)

#read(path, context: nil) ⇒ Object



22
# File 'lib/little_ghost/sandbox/isolated_backend.rb', line 22

def read(path, context: nil) = default_scope.read(path, context:)

#replace(path, old_text, new_text, context: nil) ⇒ Object



25
# File 'lib/little_ghost/sandbox/isolated_backend.rb', line 25

def replace(path, old_text, new_text, context: nil) = default_scope.replace(path, old_text, new_text, context:)

#writable?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/little_ghost/sandbox/isolated_backend.rb', line 18

def writable?
  capabilities.supports?(:filesystem_write) && effective_policy.process_grants(workspace).any?(&:writable?)
end

#write(path, content, context: nil) ⇒ Object



24
# File 'lib/little_ghost/sandbox/isolated_backend.rb', line 24

def write(path, content, context: nil) = default_scope.write(path, content, context:)