Module: Otto::ClassMethods
- Included in:
- Otto
- Defined in:
- lib/otto.rb
Overview
Class methods for Otto framework providing singleton access and configuration
Instance Method Summary collapse
- #default ⇒ Object
- #env?(*guesses) ⇒ Boolean
- #load(path) ⇒ Object
- #path(definition, params = {}) ⇒ Object
- #routes ⇒ Object
-
#unfreeze_for_testing(otto) ⇒ Otto
private
Test-only method to unfreeze Otto configuration.
Instance Method Details
#default ⇒ Object
243 244 245 246 |
# File 'lib/otto.rb', line 243 def default @default ||= Otto.new @default end |
#env?(*guesses) ⇒ Boolean
260 261 262 |
# File 'lib/otto.rb', line 260 def env? *guesses guesses.flatten.any? { |n| ENV['RACK_ENV'].to_s == n.to_s } end |
#load(path) ⇒ Object
248 249 250 |
# File 'lib/otto.rb', line 248 def load(path) default.load path end |
#path(definition, params = {}) ⇒ Object
252 253 254 |
# File 'lib/otto.rb', line 252 def path(definition, params = {}) default.path definition, params end |
#routes ⇒ Object
256 257 258 |
# File 'lib/otto.rb', line 256 def routes default.routes end |
#unfreeze_for_testing(otto) ⇒ Otto
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test-only method to unfreeze Otto configuration
This method resets the @configuration_frozen flag, allowing tests to bypass the ensure_not_frozen! check. It does NOT actually unfreeze Ruby objects (which is impossible once frozen).
IMPORTANT: Only works when RSpec is defined. Raises an error otherwise to prevent accidental use in production.
277 278 279 280 281 282 |
# File 'lib/otto.rb', line 277 def unfreeze_for_testing(otto) raise 'Otto.unfreeze_for_testing is only available in RSpec test environment' unless defined?(RSpec) otto.instance_variable_set(:@configuration_frozen, false) otto end |