Sha256: bd31a178190ee0cc9fdcb63d356f4371eace684a456f8ae8dca41187b07d772c

Contents?: true

Size: 847 Bytes

Versions: 2

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

module Sandboxy
  class << self
    attr_accessor :configuration

    def environment
      $sandboxy ||= Sandboxy.configuration.default
      $sandboxy
    end

    def environment=(value)
      $sandboxy = value
    end

    def method_missing(method, *args)
      if method.to_s[/(.+)_environment?/]
        environment?($1)
      else
        super
      end
    end

    def respond_to_missing?(method, include_private = false)
      super || method.to_s[/(.+)_environment?/]
    end

    def environment?(value)
      environment == value
    end
  end

  def self.configure
    self.configuration ||= Configuration.new
    yield configuration
  end

  class Configuration
    attr_accessor :default
    attr_accessor :retain

    def initialize
      @default = 'live'
      @retain = false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sandboxy-3.0.2 lib/sandboxy/configuration.rb
sandboxy-3.0.1 lib/sandboxy/configuration.rb