class CSP::SerializedPolicy

Constants

ParseError

Attributes

directives[R]

Public Class Methods

new(value_str) click to toggle source
# File lib/serialized_policy.rb, line 10
def initialize(value_str)
  @value_str = value_str
  @match = @value_str.match(regexp)

  raise ParseError, @value_str if @match.nil?

  @directives = @value_str.split(";").map do |directive_str|
    CSP::Directive.new(directive_str.strip)
  end
end

Public Instance Methods

to_s() click to toggle source
# File lib/serialized_policy.rb, line 21
def to_s
  @value_str
end

Private Instance Methods

regexp() click to toggle source
# File lib/serialized_policy.rb, line 29
def regexp
  /\A#{CSP::Grammar::SERIALIZED_POLICY}\z/o
end