module Pliny::CastingConfigHelpers
Public Instance Methods
Source
Source
# File lib/pliny/config_helpers.rb, line 3 def mandatory(name, method=nil) value = cast(ENV.fetch(name.to_s.upcase), method) create(name, value) end
Source
# File lib/pliny/config_helpers.rb, line 8 def optional(name, method=nil) value = cast(ENV[name.to_s.upcase], method) create(name, value) end
Source
# File lib/pliny/config_helpers.rb, line 13 def override(name, default, method=nil) value = cast(ENV.fetch(name.to_s.upcase, default), method) create(name, value) end
Source
# File lib/pliny/config_helpers.rb, line 64 def pliny_env warn "Config.pliny_env is deprecated and will be removed, " \ "use Config.app_env instead." env end
DEPRECATED: pliny_env
is deprecated in favour of app_env.
See more at https://github.com/interagent/pliny/issues/277
This method is kept temporary in case it is used somewhere in the app.
Source
# File lib/pliny/config_helpers.rb, line 52 def rack_env if env == "development" || env == "test" "development" else "deployment" end end
Private Instance Methods
Source
# File lib/pliny/config_helpers.rb, line 72 def cast(value, method) method ? method.call(value) : value end
Source
# File lib/pliny/config_helpers.rb, line 76 def create(name, value) instance_variable_set(:"@#{name}", value) instance_eval "def #{name}; @#{name} end", __FILE__, __LINE__ if value.kind_of?(TrueClass) || value.kind_of?(FalseClass) || value.kind_of?(NilClass) instance_eval "def #{name}?; !!@#{name} end", __FILE__, __LINE__ end end
Source
# File lib/pliny/config_helpers.rb, line 85 def env legacy_env || app_env end
This method helps with transition from PLINY_ENV to APP_ENV.
Source
# File lib/pliny/config_helpers.rb, line 90 def legacy_env if ENV.key?('PLINY_ENV') warn "PLINY_ENV is deprecated in favour of APP_ENV, " \ "update .env file or application configuration." ENV['PLINY_ENV'] end end
PLINY_ENV is deprecated, but it might be still used by someone.