Class: Sinatra::Default
- Defined in:
- lib/sinatra/base.rb,
lib/sinatra/main.rb,
lib/sinatra/compat.rb
Overview
Base class for classic style (top-level) applications.
Direct Known Subclasses
Defined Under Namespace
Classes: Options
Instance Attribute Summary
Attributes inherited from Base
#app, #env, #params, #request, #response
Class Method Summary collapse
-
.configures(*args, &block) ⇒ Object
Deprecated.
-
.const_missing(const_name) ⇒ Object
:nodoc:.
-
.default_options ⇒ Object
Deprecated.
-
.env ⇒ Object
Deprecated.
-
.env=(value) ⇒ Object
Deprecated.
-
.options ⇒ Object
Deprecated.
-
.register(*extensions, &block) ⇒ Object
:nodoc:.
-
.set_option(*args, &block) ⇒ Object
Deprecated.
- .set_options(*args, &block) ⇒ Object
Instance Method Summary collapse
-
#entity_tag(*args, &block) ⇒ Object
Deprecated.
-
#headers(header = nil) ⇒ Object
(also: #header)
Deprecated.
-
#invoke(&block) ⇒ Object
Throwing halt with a Symbol and the to_result convention are deprecated.
-
#method_missing(name, *args, &b) ⇒ Object
Deprecated.
-
#options ⇒ Object
:nodoc:.
-
#stop(*args, &block) ⇒ Object
Deprecated.
Methods inherited from Base
before, #call, call, #call!, condition, configure, delete, development?, disable, enable, error, get, #halt, head, helpers, #initialize, layout, media_type, not_found, #pass, post, production?, put, reload!, run!, set, template, test?, use, use_in_file_templates!
Methods included from Templates
Methods included from Helpers
#attachment, #back, #body, #content_type, #error, #etag, #last_modified, #media_type, #not_found, #redirect, #send_file, #session, #status
Constructor Details
This class inherits a constructor from Sinatra::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &b) ⇒ Object
Deprecated. Missing messages are no longer delegated to @response.
189 190 191 192 193 194 195 196 |
# File 'lib/sinatra/compat.rb', line 189 def method_missing(name, *args, &b) #:nodoc: if @response.respond_to?(name) sinatra_warn "The '#{name}' method is deprecated; use 'response.#{name}' instead." @response.send(name, *args, &b) else super end end |
Class Method Details
.configures(*args, &block) ⇒ Object
Deprecated. Use: configure
151 152 153 154 |
# File 'lib/sinatra/compat.rb', line 151 def configures(*args, &block) sinatra_warn "The 'configures' method is deprecated; use 'configure' instead." configure(*args, &block) end |
.const_missing(const_name) ⇒ Object
:nodoc:
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/sinatra/compat.rb', line 78 def self.const_missing(const_name) #:nodoc: if const_name == :FORWARD_METHODS sinatra_warn 'Sinatra::Application::FORWARD_METHODS is deprecated;', 'use Sinatra::Delegator::METHODS instead.' const_set :FORWARD_METHODS, Sinatra::Delegator::METHODS Sinatra::Delegator::METHODS else super end end |
.default_options ⇒ Object
Deprecated. Use: set
157 158 159 160 161 162 |
# File 'lib/sinatra/compat.rb', line 157 def sinatra_warn "Sinatra::Application.default_options is deprecated; use 'set' instead." fake = lambda { || set() } def fake.merge!() ; call() ; end fake end |
.env ⇒ Object
Deprecated. Use: options.environment
182 183 184 185 |
# File 'lib/sinatra/compat.rb', line 182 def env sinatra_warn "The :env option is deprecated; use :environment instead." environment end |
.env=(value) ⇒ Object
Deprecated. Use: set :environment, ENV
176 177 178 179 |
# File 'lib/sinatra/compat.rb', line 176 def env=(value) sinatra_warn "The :env option is deprecated; use :environment instead." set :environment, value end |
.options ⇒ Object
Deprecated. Options are stored directly on the class object.
145 146 147 148 |
# File 'lib/sinatra/compat.rb', line 145 def sinatra_warn "The 'options' class method is deprecated; use 'self' instead." Options.new(self) end |
.register(*extensions, &block) ⇒ Object
:nodoc:
927 928 929 930 931 |
# File 'lib/sinatra/base.rb', line 927 def self.register(*extensions, &block) #:nodoc: added_methods = extensions.map {|m| m.public_instance_methods }.flatten Delegator.delegate *added_methods super(*extensions, &block) end |
.set_option(*args, &block) ⇒ Object
Deprecated. Use: set
165 166 167 168 |
# File 'lib/sinatra/compat.rb', line 165 def set_option(*args, &block) sinatra_warn "The 'set_option' method is deprecated; use 'set' instead." set(*args, &block) end |
.set_options(*args, &block) ⇒ Object
170 171 172 173 |
# File 'lib/sinatra/compat.rb', line 170 def (*args, &block) sinatra_warn "The 'set_options' method is deprecated; use 'set' instead." set(*args, &block) end |
Instance Method Details
#entity_tag(*args, &block) ⇒ Object
Deprecated. Use: etag
104 105 106 107 |
# File 'lib/sinatra/compat.rb', line 104 def entity_tag(*args, &block) sinatra_warn "The 'entity_tag' method is deprecated; use 'etag' instead." etag(*args, &block) end |
#headers(header = nil) ⇒ Object Also known as: header
Deprecated. Use: response
90 91 92 93 94 |
# File 'lib/sinatra/compat.rb', line 90 def headers(header=nil) sinatra_warn "The 'headers' method is deprecated; use 'response' instead." response.headers.merge!(header) if header response.headers end |
#invoke(&block) ⇒ Object
Throwing halt with a Symbol and the to_result convention are deprecated. Override the invoke method to detect those types of return values.
112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/sinatra/compat.rb', line 112 def invoke(&block) #:nodoc: res = super case when res.kind_of?(Symbol) sinatra_warn "Invoking the :#{res} helper by returning a Symbol is deprecated;", "call the helper directly instead." @response.body = __send__(res) when res.respond_to?(:to_result) sinatra_warn "The to_result convention is deprecated." @response.body = res.to_result(self) end res end |
#options ⇒ Object
:nodoc:
126 127 128 |
# File 'lib/sinatra/compat.rb', line 126 def #:nodoc: Options.new(self.class) end |
#stop(*args, &block) ⇒ Object
Deprecated. Use: halt
98 99 100 101 |
# File 'lib/sinatra/compat.rb', line 98 def stop(*args, &block) sinatra_warn "The 'stop' method is deprecated; use 'halt' instead." halt(*args, &block) end |