Class: CSPEasyRails

Inherits:
Object
  • Object
show all
Defined in:
lib/csp_easy_rails.rb

Class Method Summary collapse

Class Method Details

.policy(file) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/csp_easy_rails.rb', line 4

def self.policy(file)
  config = YAML::load(File.read(file))
  config.each do |key, value|
    config[key] = "'#{value}'" if value == "self" || value == "none"
    config[key] = value.join(" ") if value.class == Array
  end
  
  policy_string = ""
  config.each do |key, value|
    policy_string = policy_string + "#{key} #{value}; "
  end
  
  policy_string.strip
end