Class: ActiveSupport::EnvironmentInquirer

Inherits:
StringInquirer show all
Defined in:
lib/active_support/environment_inquirer.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_ENVIRONMENTS =

Optimization for the three default environments, so this inquirer doesn’t need to rely on the slower delegation through method_missing that StringInquirer would normally entail.

%w[ development test production ]
LOCAL_ENVIRONMENTS =

Environments that’ll respond true for #local?

%w[ development test ]

Constants inherited from String

String::BLANK_RE, String::ENCODED_BLANKS

Instance Method Summary collapse

Methods inherited from String

#acts_like_string?, #as_json, #at, #blank?, #camelize, #classify, #constantize, #dasherize, #deconstantize, #demodulize, #downcase_first, #exclude?, #first, #foreign_key, #from, #html_safe, #humanize, #in_time_zone, #indent, #indent!, #inquiry, #is_utf8?, #last, #mb_chars, #parameterize, #pluralize, #remove, #remove!, #safe_constantize, #singularize, #squish, #squish!, #strip_heredoc, #tableize, #titleize, #to, #to_date, #to_datetime, #to_time, #truncate, #truncate_bytes, #truncate_words, #underscore, #upcase_first

Constructor Details

#initialize(env) ⇒ EnvironmentInquirer

Returns a new instance of EnvironmentInquirer.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_support/environment_inquirer.rb', line 15

def initialize(env)
  raise(ArgumentError, "'local' is a reserved environment name") if env == "local"

  super(env)

  DEFAULT_ENVIRONMENTS.each do |default|
    instance_variable_set :"@#{default}", env == default
  end

  @local = in? LOCAL_ENVIRONMENTS
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveSupport::StringInquirer

Instance Method Details

#local?Boolean

Returns true if we’re in the development or test environment.

Returns:

  • (Boolean)


36
37
38
# File 'lib/active_support/environment_inquirer.rb', line 36

def local?
  @local
end