Module: SecureHeaders::DynamicConfig
- Included in:
- ContentSecurityPolicyConfig
- Defined in:
- lib/secure_headers/headers/content_security_policy_config.rb
Instance Method Summary collapse
- #==(o) ⇒ Object
- #append(new_hash) ⇒ Object
- #directive_value(directive) ⇒ Object (also: #[])
- #dup ⇒ Object
- #initialize(hash) ⇒ Object
- #initialize_copy(hash) ⇒ Object
- #merge(new_hash) ⇒ Object
- #merge!(new_hash) ⇒ Object
- #opt_out? ⇒ Boolean
- #to_h ⇒ Object
- #update_directive(directive, value) ⇒ Object (also: #[]=)
Instance Method Details
#==(o) ⇒ Object
49 50 51 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 49 def ==(o) self.class == o.class && self.to_h == o.to_h end |
#append(new_hash) ⇒ Object
33 34 35 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 33 def append(new_hash) from_hash(ContentSecurityPolicy.combine_policies(self.to_h, new_hash)) end |
#directive_value(directive) ⇒ Object Also known as: []
18 19 20 21 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 18 def directive_value(directive) # No need to check attrs, as we only assign valid keys @config[directive] end |
#dup ⇒ Object
41 42 43 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 41 def dup self.class.new(self.to_h) end |
#initialize(hash) ⇒ Object
4 5 6 7 8 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 4 def initialize(hash) @config = {} from_hash(hash) end |
#initialize_copy(hash) ⇒ Object
10 11 12 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 10 def initialize_copy(hash) @config = hash.to_h end |
#merge(new_hash) ⇒ Object
23 24 25 26 27 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 23 def merge(new_hash) new_config = self.dup new_config.send(:from_hash, new_hash) new_config end |
#merge!(new_hash) ⇒ Object
29 30 31 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 29 def merge!(new_hash) from_hash(new_hash) end |
#opt_out? ⇒ Boolean
45 46 47 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 45 def opt_out? false end |
#to_h ⇒ Object
37 38 39 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 37 def to_h @config.dup end |
#update_directive(directive, value) ⇒ Object Also known as: []=
14 15 16 |
# File 'lib/secure_headers/headers/content_security_policy_config.rb', line 14 def update_directive(directive, value) @config[directive] = value end |