Sha256: bc09e419f9dc213c330daeabb580763f6b98030dab06d73f18202e358a0ca88f

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

require 'singleton'

module Akatus

  def self.configuracao
    Configuracao.instance
  end

  #
  # Private.
  #
  private

  class Configuracao
    include Singleton

    attr_accessor :env, :sandbox, :url_carrinho

    #
    # Private methods.
    #
    private

    def initialize
      if defined? Rails
        path = "#{Rails.root}/config/akatus.yml"
        self.env = Rails.env
      else
        path = "#{Dir.pwd}/config/akatus.yml"
        self.env = ENV['AKATUS_ENV'] || 'development'
      end
      conf = File.exists?(path) ? YAML.load_file(path)[self.env] : {}

      self.sandbox = conf['sandbox'].present? && conf['sandbox'] == true
      self.url_carrinho = self.sandbox ? 'https://dev.akatus.com/carrinho/' : 'https://www.akatus.com/carrinho/'
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
akatus-0.1.0 lib/akatus/configuracao.rb