Class: EnvStringHandler
- Inherits:
-
String
- Object
- String
- EnvStringHandler
- Defined in:
- lib/skn_utils/env_string_handler.rb
Overview
File: ./lib/skn_utils/env_string_handler.rb
Wrapping a string in this class gives you a prettier way to test for equality. The value returned by Rails.env is wrapped in a StringInquirer object so instead of calling this:
Rails.env == 'production'
SknSettings.env == 'production'
you can call this:
Rails.env.production?
SknSettings.env.productcion?
Create a EnvStringHandler to support: SknSettings.env.development? Yes, its YAML trick in config/settings.yml
...
env: !ruby/string:EnvStringHandler <%= ENV['RACK_ENV'] %>
...
#
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments) ⇒ Object (private)
29 30 31 32 33 34 35 |
# File 'lib/skn_utils/env_string_handler.rb', line 29 def method_missing(method_name, *arguments) if method_name[-1] == '?' self == method_name[0..-2] else super end end |