Class: Trinity::Handler
- Inherits:
-
Object
- Object
- Trinity::Handler
- Defined in:
- lib/trinity/handler.rb,
lib/trinity/handler/loader.rb,
lib/trinity/handler/aliaser.rb,
lib/trinity/handler/acceptor.rb,
lib/trinity/handler/reasoner.rb,
lib/trinity/handler/dispatcher.rb,
lib/trinity/handler/redirector.rb,
lib/trinity/handler/initializer.rb
Instance Attribute Summary
- - (Object) application readonly Returns the value of attribute application.
- - (Object) repository readonly Returns the value of attribute repository.
Instance Method Summary
- - (Object) call(env)
- - (Handler) initialize(application, repository = nil) constructor A new instance of Handler.
- - (Object) not_found
- - (Object) query(*args, &block) Query the repository for statements matching the given pattern.
- - (Object) redirect(url)
Constructor Details
- (Handler) initialize(application, repository = nil)
A new instance of Handler
15 16 17 18 |
# File 'lib/trinity/handler.rb', line 15 def initialize(application, repository = nil) @application = application @repository = repository end |
Instance Attribute Details
- (Object) application (readonly)
Returns the value of attribute application
12 13 14 |
# File 'lib/trinity/handler.rb', line 12 def application @application end |
- (Object) repository (readonly)
Returns the value of attribute repository
13 14 15 |
# File 'lib/trinity/handler.rb', line 13 def repository @repository end |
Instance Method Details
- (Object) call(env)
20 21 22 |
# File 'lib/trinity/handler.rb', line 20 def call(env) application.call(env) end |
- (Object) not_found
40 41 42 |
# File 'lib/trinity/handler.rb', line 40 def not_found [404, {'Content-Type' => 'text/plain'}, '404 Resource Not Found'] end |
- (Object) query(*args, &block)
Query the repository for statements matching the given pattern
28 29 30 31 32 33 34 |
# File 'lib/trinity/handler.rb', line 28 def query(*args, &block) if block_given? repository.query(*args, &block) else repository.query(*args).extend(RDF::Enumerable) end end |
- (Object) redirect(url)
36 37 38 |
# File 'lib/trinity/handler.rb', line 36 def redirect(url) [301, {'Content-Type' => 'text/plain', 'Location' => url}, "301 Moved Permanently to #{url}"] end |