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
306 307 308 309 |
# File 'lib/otto.rb', line 306 def default @default ||= Otto.new @default end |
#env?(*guesses) ⇒ Boolean
323 324 325 |
# File 'lib/otto.rb', line 323 def env? *guesses guesses.flatten.any? { |n| ENV['RACK_ENV'].to_s == n.to_s } end |
#load(path) ⇒ Object
311 312 313 |
# File 'lib/otto.rb', line 311 def load(path) default.load path end |
#path(definition, params = {}) ⇒ Object
315 316 317 |
# File 'lib/otto.rb', line 315 def path(definition, params = {}) default.path definition, params end |
#routes ⇒ Object
319 320 321 |
# File 'lib/otto.rb', line 319 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.
340 341 342 343 344 345 |
# File 'lib/otto.rb', line 340 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 |