Class: Rack::Typekit

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

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Typekit

Returns a new instance of Typekit.

Raises:

  • (ArgumentError)


8
9
10
11
# File 'lib/rack/typekit.rb', line 8

def initialize(app, options = {})
  raise ArgumentError, "Typekit Kit ID Required" unless options[:kit] and !options[:kit].empty?
  @app, @options = app, options
end

Instance Method Details

#_call(env) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/rack/typekit.rb', line 15

def _call(env)
  @status, @headers, @response = @app.call(env)
  return [@status, @headers, @response] unless html?
  response = Rack::Response.new([], @status, @headers)
  @response.each { |fragment| response.write inject(fragment) }
  response.finish
end

#call(env) ⇒ Object



13
# File 'lib/rack/typekit.rb', line 13

def call(env); dup._call(env); end