Sha256: c160262fef34018090dea25c0cc11d6b62a0f52873b3b9625fe56a7cb2be7ba6

Contents?: true

Size: 638 Bytes

Versions: 17

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

class Rage::Env
  STANDARD_ENVS = %w(development test staging production)

  def initialize(env)
    @env = env

    STANDARD_ENVS.each do |standard_env|
      self.class.define_method("#{standard_env}?") { false } if standard_env != @env
    end
    self.class.define_method("#{@env}?") { true }
  end

  def method_missing(method_name, *, &)
    method_name.end_with?("?") ? false : super
  end

  def respond_to_missing?(method_name, include_private = false)
    method_name.end_with?("?")
  end

  def ==(other)
    @env == other
  end

  def to_sym
    @env.to_sym
  end

  def to_s
    @env
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rage-rb-1.11.0 lib/rage/env.rb
rage-rb-1.10.1 lib/rage/env.rb
rage-rb-1.10.0 lib/rage/env.rb
rage-rb-1.9.0 lib/rage/env.rb
rage-rb-1.8.0 lib/rage/env.rb
rage-rb-1.7.0 lib/rage/env.rb
rage-rb-1.6.0 lib/rage/env.rb
rage-rb-1.4.0 lib/rage/env.rb
rage-rb-1.3.0 lib/rage/env.rb
rage-rb-1.2.2 lib/rage/env.rb
rage-rb-1.2.1 lib/rage/env.rb
rage-rb-1.2.0 lib/rage/env.rb
rage-rb-1.1.0 lib/rage/env.rb
rage-rb-1.0.0 lib/rage/env.rb
rage-rb-0.7.0 lib/rage/env.rb
rage-rb-0.6.0 lib/rage/env.rb
rage-rb-0.5.2 lib/rage/env.rb