Class: HTTP::Security::Headers::XFrameOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/http/security/headers/x_frame_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directives = {}) ⇒ XFrameOptions

Returns a new instance of XFrameOptions.



8
9
10
11
12
13
# File 'lib/http/security/headers/x_frame_options.rb', line 8

def initialize(directives={})
  @deny        = directives[:deny]
  @same_origin = directives[:sameorigin]
  @allow_from  = directives[:allow_from]
  @allow_all   = directives[:allowall]
end

Instance Attribute Details

#allow_fromObject (readonly)

Returns the value of attribute allow_from.



6
7
8
# File 'lib/http/security/headers/x_frame_options.rb', line 6

def allow_from
  @allow_from
end

Instance Method Details

#allow_all?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/http/security/headers/x_frame_options.rb', line 23

def allow_all?
  !!@allow_all
end

#deny?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/http/security/headers/x_frame_options.rb', line 15

def deny?
  !!@deny
end

#same_origin?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/http/security/headers/x_frame_options.rb', line 19

def same_origin?
  !!@same_origin
end

#to_sObject



27
28
29
30
31
32
33
34
# File 'lib/http/security/headers/x_frame_options.rb', line 27

def to_s
  if    @deny        then 'DENY'
  elsif @same_origin then 'SAMEORIGIN'
  elsif @allow_from  then "ALLOW-FROM #{@allow_from}"
  elsif @allow_all   then 'ALLOWALL'
  else                    ''
  end
end