Class: Terminalwire::Client::Entitlement::Policy::Base
- Inherits:
-
Object
- Object
- Terminalwire::Client::Entitlement::Policy::Base
- Defined in:
- lib/terminalwire/client/entitlement/policy.rb
Overview
A policy has the authority, paths, and schemes that the server is allowed to access.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#authority ⇒ Object
readonly
Returns the value of attribute authority.
-
#environment_variables ⇒ Object
readonly
Returns the value of attribute environment_variables.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#schemes ⇒ Object
readonly
Returns the value of attribute schemes.
Instance Method Summary collapse
- #authority_path ⇒ Object
-
#initialize(authority:) ⇒ Base
constructor
A new instance of Base.
- #root_path ⇒ Object
- #serialize ⇒ Object
- #storage_path ⇒ Object
- #storage_pattern ⇒ Object
Constructor Details
#initialize(authority:) ⇒ Base
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 7 def initialize(authority:) = @paths = Paths.new # Permit the domain directory. This is necessary for basic operation of the client. @paths.permit storage_path @paths.permit storage_pattern @schemes = Schemes.new # Permit http & https by default. @schemes.permit "http" @schemes.permit "https" @environment_variables = EnvironmentVariables.new # Permit the HOME and TERMINALWIRE_HOME environment variables. @environment_variables.permit "TERMINALWIRE_HOME" end |
Instance Attribute Details
#authority ⇒ Object (readonly)
Returns the value of attribute authority.
5 6 7 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 5 def end |
#environment_variables ⇒ Object (readonly)
Returns the value of attribute environment_variables.
5 6 7 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 5 def environment_variables @environment_variables end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
5 6 7 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 5 def paths @paths end |
#schemes ⇒ Object (readonly)
Returns the value of attribute schemes.
5 6 7 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 5 def schemes @schemes end |
Instance Method Details
#authority_path ⇒ Object
30 31 32 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 30 def root_path.join("authorities/#{authority}") end |
#root_path ⇒ Object
25 26 27 28 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 25 def root_path # TODO: This needs to be passed into the Policy so that it can be set by the client. Terminalwire::Client.root_path end |
#serialize ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 42 def serialize { authority: , schemes: @schemes.serialize, paths: @paths.serialize, environment_variables: @environment_variables.serialize } end |
#storage_path ⇒ Object
34 35 36 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 34 def storage_path .join("storage") end |
#storage_pattern ⇒ Object
38 39 40 |
# File 'lib/terminalwire/client/entitlement/policy.rb', line 38 def storage_pattern storage_path.join("**/*") end |