Sha256: ccdfc79f4c27e5a5fd1d8ccf676ab932b76658526a605bc67ab9e38bac6577a3

Contents?: true

Size: 1.06 KB

Versions: 18

Compression:

Stored size: 1.06 KB

Contents

require 'singleton'

module Unimatrix

  def self.configuration( &block )
    Configuration.instance().instance_eval( &block ) unless block.nil?
    Configuration.instance()
  end

  class Configuration
    include Singleton

    def self.field( field_name, options={} )
      class_eval(
        "def #{ field_name }( *arguments ); " +
           "@#{ field_name } = arguments.first unless arguments.empty?; " +
           "@#{ field_name } || " +
             ( options[ :default ].nil? ?
                "nil" :
                ( options[ :default ].is_a?( String ) ?
                    "'#{ options[ :default ] }'" :
                      "#{ options[ :default ] }" ) ) + ";" +
        "end",
        __FILE__,
        __LINE__
      )
    end

    field :url,                default: ENV[ 'UNIMATRIX_API_URL' ] || 
                                        'http://us-west-2.api.unimatrix.io'
    
    field :authorization_url,  default: ENV[ 'UNIMATRIX_AUTHORIZATION_API_URL' ] || 
                                        'http://us-west-2.keymaker.boxxspring.net'
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
unimatrix-2.9.0 lib/unimatrix/configuration.rb
unimatrix-2.8.0 lib/unimatrix/configuration.rb
unimatrix-2.7.1 lib/unimatrix/configuration.rb
unimatrix-2.7.0 lib/unimatrix/configuration.rb
unimatrix-2.6.1 lib/unimatrix/configuration.rb
unimatrix-2.6.0 lib/unimatrix/configuration.rb
unimatrix-2.5.5 lib/unimatrix/configuration.rb
unimatrix-2.5.4 lib/unimatrix/configuration.rb
unimatrix-2.5.3 lib/unimatrix/configuration.rb
unimatrix-2.5.2 lib/unimatrix/configuration.rb
unimatrix-2.5.1 lib/unimatrix/configuration.rb
unimatrix-2.5.0 lib/unimatrix/configuration.rb
unimatrix-2.4.2 lib/unimatrix/configuration.rb
unimatrix-2.3.1 lib/unimatrix/configuration.rb
unimatrix-2.2.1 lib/unimatrix/configuration.rb
unimatrix-2.1.1 lib/unimatrix/configuration.rb
unimatrix-2.0.1 lib/unimatrix/configuration.rb
unimatrix-2.0.0 lib/unimatrix/configuration.rb