Class: Orbit::Application
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
- #config ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #load_middleware ⇒ Object
- #setup_builder ⇒ Object
- #start ⇒ Object
- #use_protection ⇒ Object
- #use_session(options) ⇒ Object
Methods included from Singleton
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
13 14 15 16 17 18 19 20 21 |
# File 'lib/orbit.rb', line 13 def initialize instantiate setup_builder load_middleware loader = Loaders::DirectoryLoader.load @reloader = loader.reloader end |
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
11 12 13 |
# File 'lib/orbit.rb', line 11 def builder @builder end |
Class Method Details
.config ⇒ Object
51 52 53 |
# File 'lib/orbit.rb', line 51 def self.config @config ||= Orbit::Config.instance end |
.configure {|config| ... } ⇒ Object
59 60 61 |
# File 'lib/orbit.rb', line 59 def self.configure yield config end |
.start ⇒ Object
63 64 65 66 67 |
# File 'lib/orbit.rb', line 63 def self.start instance || new instance.start end |
Instance Method Details
#call(env) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/orbit.rb', line 74 def call(env) @reloader.reload @request = config.request_class.new(env) verb = @request.request_method requested_path = @request.path_info route = Config.router_class.match(verb, requested_path) if route intercepted = Interceptors::List.intercept_path(@request) return intercepted if intercepted route_params = route[:route].path.get_params(requested_path) || {} @request.params.merge!(route_params) begin route[:class].execute_action(@request, route[:action]) rescue Exception => exception Config.response_class.server_error(exception, verb, requested_path) end else Config.response_class.not_found(verb, requested_path) end end |
#config ⇒ Object
55 56 57 |
# File 'lib/orbit.rb', line 55 def config self.class.config end |
#load_middleware ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/orbit.rb', line 27 def load_middleware builder.use Rack::MethodOverride builder.use Rack::Head builder.use Rack::Static, :urls => Config.static_files_path builder.use config.rack_logger_class use_session(config.) use_protection end |
#setup_builder ⇒ Object
23 24 25 |
# File 'lib/orbit.rb', line 23 def setup_builder @builder = Rack::Builder.new end |
#start ⇒ Object
69 70 71 72 |
# File 'lib/orbit.rb', line 69 def start builder.run self builder end |
#use_protection ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/orbit.rb', line 43 def use_protection = {} [:except] = Array [:except] [:except] += [:session_hijacking, :remote_token] [:reaction] ||= :drop_session builder.use Rack::Protection, end |
#use_session(options) ⇒ Object
37 38 39 40 41 |
# File 'lib/orbit.rb', line 37 def use_session() [:secret] = config.session_secret builder.use Rack::Session::Cookie, end |