Sha256: ac655364f6462e77811beff14de658e4d7711501982a6a5ca6efec49eb9cb647

Contents?: true

Size: 556 Bytes

Versions: 6

Compression:

Stored size: 556 Bytes

Contents

module Tamashii
  class Environment < Hash

    RUNTIME_ENV = %w(test development production)

    def initialize(env = nil, **options)
      self.merge!(options)
      self[:env] = env.to_s unless env.nil?
    end

    def method_missing(name, *args, &block)
      return is_env(name[0..-2]) if RUNTIME_ENV.include?(name[0..-2])
      super
    end

    def ==(other)
      self.to_s == other.to_s
    end

    def is_env(env)
      self.to_s == env.to_s
    end

    def to_s
      (self[:env] || ENV['RACK_ENV'] || "development").to_s
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tamashii-common-0.2.0 lib/tamashii/environment.rb
tamashii-common-0.1.6 lib/tamashii/environment.rb
tamashii-common-0.1.5 lib/tamashii/environment.rb
tamashii-common-0.1.4 lib/tamashii/environment.rb
tamashii-common-0.1.3 lib/tamashii/environment.rb
tamashii-common-0.1.2 lib/tamashii/environment.rb