Class: ForemanVault::VaultPolicy
- Inherits:
-
Object
- Object
- ForemanVault::VaultPolicy
- Defined in:
- app/services/foreman_vault/vault_policy.rb
Constant Summary collapse
- MAGIC_COMMENT_NAME_PREFIX =
'# NAME: '
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(host) ⇒ VaultPolicy
constructor
A new instance of VaultPolicy.
- #name ⇒ Object
- #new? ⇒ Boolean
- #save ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(host) ⇒ VaultPolicy
Returns a new instance of VaultPolicy.
7 8 9 |
# File 'app/services/foreman_vault/vault_policy.rb', line 7 def initialize(host) @host = host end |
Instance Method Details
#delete ⇒ Object
31 32 33 34 35 |
# File 'app/services/foreman_vault/vault_policy.rb', line 31 def delete return false unless valid? delete_policy(name) end |
#name ⇒ Object
15 16 17 |
# File 'app/services/foreman_vault/vault_policy.rb', line 15 def name magic_comment_name&.chomp&.remove(MAGIC_COMMENT_NAME_PREFIX)&.parameterize end |
#new? ⇒ Boolean
19 20 21 22 23 |
# File 'app/services/foreman_vault/vault_policy.rb', line 19 def new? return unless name policies.index(name).nil? end |
#save ⇒ Object
25 26 27 28 29 |
# File 'app/services/foreman_vault/vault_policy.rb', line 25 def save return false unless valid? put_policy(name, rules) end |
#valid? ⇒ Boolean
11 12 13 |
# File 'app/services/foreman_vault/vault_policy.rb', line 11 def valid? name.present? && rules.present? end |