Class: Roda::RodaPlugins::Unpoly::Inspector

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/roda/plugins/unpoly.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Inspector

:nodoc:



17
18
19
# File 'lib/roda/plugins/unpoly.rb', line 17

def initialize(context) # :nodoc:
  @context = context
end

Instance Method Details

#targetObject

The actual target as requested by Unpoly.



47
48
49
# File 'lib/roda/plugins/unpoly.rb', line 47

def target
  get_header("HTTP_X_UP_TARGET")
end

#target?(tested_target) ⇒ Boolean

Identify if the tested_target will match the actual target requested.

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/roda/plugins/unpoly.rb', line 28

def target?(tested_target)
  if up?
    actual_target = target

    if actual_target == tested_target
      true
    elsif actual_target == "html"
      true
    elsif actual_target == "body"
      !%w(head title meta).include?(tested_target)
    else
      false
    end
  else
    true
  end
end

#title=(new_title) ⇒ Object

Set the page title.



52
53
54
# File 'lib/roda/plugins/unpoly.rb', line 52

def title=(new_title)
  response.headers["X-Up-Title"] = new_title
end

#unpoly?Boolean Also known as: up?

Determine if this is an Unpoly request.

Returns:

  • (Boolean)


22
23
24
# File 'lib/roda/plugins/unpoly.rb', line 22

def unpoly?
  target.to_s.strip != ""
end

#validate?Boolean

Determine if this is a validate request.

Returns:

  • (Boolean)


57
58
59
# File 'lib/roda/plugins/unpoly.rb', line 57

def validate?
  get_header("HTTP_X_UP_VALIDATE").to_s.strip != ""
end