Module: Roy
- Defined in:
- lib/roy/base.rb,
lib/roy/halt.rb,
lib/roy/after.rb,
lib/roy/before.rb,
lib/roy/render.rb,
lib/roy/version.rb,
lib/roy/context.rb,
lib/roy/basic_auth.rb
Overview
This is the main module that applications should include.
Defined Under Namespace
Modules: After, BasicAuth, Before, ClassMethods, Halt, Render Classes: Context
Constant Summary
- Defaults =
Default options.
{allow: [:get], prefix: :', use: [:halt]}
- VERSION =
[0, 5, 2]
Class Method Summary (collapse)
-
+ (Object) included(base)
Extend the class with the ClassMethods module.
-
+ (Object) version
Return the version as a String.
Instance Method Summary (collapse)
-
- (Object) call(env)
A Rack-compliant #call method.
-
- (Object) roy
Returns the application context or initialize it.
Class Method Details
+ (Object) included(base)
Extend the class with the ClassMethods module.
19 20 21 |
# File 'lib/roy/base.rb', line 19 def self.included(base) base.send(:extend, ClassMethods) end |
+ (Object) version
Return the version as a String.
5 6 7 |
# File 'lib/roy/version.rb', line 5 def self.version VERSION.join('.') end |
Instance Method Details
- (Object) call(env)
A Rack-compliant #call method.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/roy/base.rb', line 29 def call(env) roy.prepare!(env) method = roy.env['REQUEST_METHOD'].downcase.to_sym roy.env['PATH_INFO'].sub!(/^([^\/])/, '/\1') method, was_head = :get, true if method == :head roy.response.status, body = catch(:halt) do roy.halt(405) unless roy.conf.allow.include?(method) prefixed_method = :#{roy.conf.prefix}#{method}" [roy.response.status, send(prefixed_method, roy.env['PATH_INFO'])] end roy.response.write(body) unless was_head roy.response.finish end |
- (Object) roy
Returns the application context or initialize it
24 25 26 |
# File 'lib/roy/base.rb', line 24 def roy @roy ||= Context.new(self) end |