Class: ObjectsFramework::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/objectsframework/object.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_hook(hook) ⇒ Object



40
41
42
# File 'lib/objectsframework/object.rb', line 40

def self.add_hook(hook)
	@hooks << hook
end

.get_hooksObject



36
37
38
# File 'lib/objectsframework/object.rb', line 36

def self.get_hooks
	@hooks
end

.inherited(klass) ⇒ Object

Object hooks: Usage: add_hook :filter => “afilter”, :method => “yourmethod” Available hooks/filters (some are not implement yet, but planned):

  • object.before_execute: fired before your request handling method is called

  • request.finished: fired when the request is finished and the response is about to get served [planned]

  • server.ready: fired when the server is ready accepting connections [planned]

  • server.error: fired when an internal error happens (for example method not found) [planned]

  • request.capture: capture the request before anything happens, like a real pirate! (fired after your object is created)

    if the result of your hook returns true, the request must be finished by your hook
    this can block the request
    

All hooks are blocking, so they could eventually block the request [Future testing required]



32
33
34
# File 'lib/objectsframework/object.rb', line 32

def self.inherited(klass)
  klass.instance_variable_set("@hooks", [])
end

Instance Method Details

#continueObject



16
17
18
# File 'lib/objectsframework/object.rb', line 16

def continue
  return 0
end

#requestObject



8
9
10
# File 'lib/objectsframework/object.rb', line 8

def request
  @request
end

#responseObject



12
13
14
# File 'lib/objectsframework/object.rb', line 12

def response
  @response
end

#set_instance_variables(request, response, env) ⇒ Object



3
4
5
6
# File 'lib/objectsframework/object.rb', line 3

def set_instance_variables(request,response,env)
  @request,@response,@env = request,response,env
  return self;
end