Class: Hobbit::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hobbit/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



47
48
49
# File 'lib/hobbit/base.rb', line 47

def env
  @env
end

#requestObject (readonly)

Returns the value of attribute request.



47
48
49
# File 'lib/hobbit/base.rb', line 47

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



47
48
49
# File 'lib/hobbit/base.rb', line 47

def response
  @response
end

Class Method Details

._newObject



14
# File 'lib/hobbit/base.rb', line 14

alias :_new :new

.call(env) ⇒ Object



20
21
22
# File 'lib/hobbit/base.rb', line 20

def call(env)
  new.call env
end

.new(*args, &block) ⇒ Object



15
16
17
18
# File 'lib/hobbit/base.rb', line 15

def new(*args, &block)
  stack.run _new(*args, &block)
  stack
end

.routesObject



24
25
26
# File 'lib/hobbit/base.rb', line 24

def routes
  @routes ||= Hash.new { |hash, key| hash[key] = [] }
end

.stackObject



28
29
30
# File 'lib/hobbit/base.rb', line 28

def stack
  @stack ||= Rack::Builder.new
end

Instance Method Details

#_call(env) ⇒ Object



53
54
55
56
57
58
# File 'lib/hobbit/base.rb', line 53

def _call(env)
  @env = env
  @request = Hobbit::Request.new @env
  @response = Hobbit::Response.new
  catch(:halt) { route_eval }
end

#call(env) ⇒ Object



49
50
51
# File 'lib/hobbit/base.rb', line 49

def call(env)
  dup._call env
end

#halt(response) ⇒ Object



60
61
62
# File 'lib/hobbit/base.rb', line 60

def halt(response)
  throw :halt, response
end