Sha256: f435b8e36982ede4c7c0c13932f2ae4540700f8ac866514a0980fb72494879bb

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

require 'active_support/configurable'

module Epom
  # Configures global settings for Epom
  #   Epom.configure do |config|
  #     config.epom_server = 'https://n29.epom.com/'
  #   end
  def self.configure(&block)
    yield @config ||= Epom::Configuration.new
  end

  # Global settings for Epom
  def self.config
    @config
  end

  # need a Class for 3.0
  class Configuration #:nodoc:
    include ActiveSupport::Configurable
    config_accessor :public_key
    config_accessor :private_key
    config_accessor :epom_server

    def param_name
      config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
    end

    # define param_name writer (copied from AS::Configurable)
    writer, line = 'def param_name=(value); config.param_name = value; end', __LINE__
    singleton_class.class_eval writer, __FILE__, line
    class_eval writer, __FILE__, line
  end

  # this is ugly. why can't we pass the default value to config_accessor...?
  configure do |config|
    config.epom_server = 'https://n29.epom.com/'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
epom-0.9.2 lib/epom/config.rb
epom-0.9.1 lib/epom/config.rb
epom-0.9 lib/epom/config.rb