Module: SecureHeaders::ClassMethods

Defined in:
lib/secure_headers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#secure_headers_optionsObject



24
25
26
27
28
29
30
31
32
# File 'lib/secure_headers.rb', line 24

def secure_headers_options
  if @secure_headers_options
    @secure_headers_options
  elsif superclass.respond_to?(:secure_headers_options) # stop at application_controller
    superclass.secure_headers_options
  else
    {}
  end
end

Instance Method Details

#ensure_security_headers(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/secure_headers.rb', line 34

def ensure_security_headers options = {}
  self.secure_headers_options = options
  before_filter :set_hsts_header
  before_filter :set_x_frame_options_header
  before_filter :set_csp_header
  before_filter :set_x_xss_protection_header
  before_filter :set_x_content_type_options_header
end

#options_for(type, options) ⇒ Object

we can’t use ||= because I’m overloading false => disable, nil => default both of which trigger the conditional assignment



45
46
47
# File 'lib/secure_headers.rb', line 45

def options_for(type, options)
  options.nil? ? ::SecureHeaders::Configuration.send(type) : options
end