Module: CloudKit::Util

Included in:
OAuthFilter, OpenIDFilter, Request, Response, Store
Defined in:
lib/cloudkit/util.rb

Instance Method Summary collapse

Instance Method Details

#erb(request, template, headers = {'Content-Type' => 'text/html'}, status = 200) ⇒ Object

Render ERB content



5
6
7
8
9
10
11
12
13
# File 'lib/cloudkit/util.rb', line 5

def erb(request, template, headers={'Content-Type' => 'text/html'}, status=200)
  template_file = open(
    File.join(File.dirname(__FILE__),
    'templates',
    "#{template.to_s}.erb"))
  template = ERB.new(template_file.read)
  result = template.result(binding)
  Rack::Response.new(result, status, headers).finish
end

#r(method, path, params = []) ⇒ Object

Build a Rack::Router instance



16
17
18
# File 'lib/cloudkit/util.rb', line 16

def r(method, path, params=[])
  Rack::Router.new(method, path, params)
end

#unquote(text) ⇒ Object

Remove the outer double quotes from a given string.



21
22
23
# File 'lib/cloudkit/util.rb', line 21

def unquote(text)
  (text =~ /^\".*\"$/) ? text[1..-2] : text
end