Sha256: afbb39cde0edefb9cbf65f016913911f991c819deeb0e7e37c3b4ff7a6cb8d07

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

module PagseguroClient
  extend self

  @@config = nil

  def config_file
    Rails.root.join("config/pagseguro.yml")
  end

  def config?
    File.exist?(config_file)
  end

  def config
    raise MissingConfigurationError, "file not found on #{config_file.inspect}" unless config?

    @@config ||= YAML.load_file(config_file)

    if @@config == false || !@@config[Rails.env]
      raise MissingEnvironmentError, ":#{Rails.env} environment not set on #{config_file.inspect}"
    end

    @@config[Rails.env]
  end
  
  def base_url
    config["base_url"]
  end
  
  def token
    config["token"]
  end
  
  def email
    config["email"]
  end

  class MissingEnvironmentError < StandardError; end
  class MissingConfigurationError < StandardError; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pagseguro_client-0.0.1 lib/pagseguro_client/base.rb