Sha256: 14696d00a45e9f4bcae74c8166e9e7d0002e61e41ae434e612339e0e4fdbe530

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 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'
                                        
    field :client_id,          default: ENV[ 'KEYMAKER_CLIENT' ]
    field :client_secret,      default: ENV[ 'KEYMAKER_SECRET' ]
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
unimatrix-3.4.0 lib/unimatrix/configuration.rb
unimatrix-3.3.4 lib/unimatrix/configuration.rb
unimatrix-3.3.3 lib/unimatrix/configuration.rb
unimatrix-3.3.2 lib/unimatrix/configuration.rb
unimatrix-3.3.1 lib/unimatrix/configuration.rb
unimatrix-3.3.0 lib/unimatrix/configuration.rb
unimatrix-3.2.0 lib/unimatrix/configuration.rb
unimatrix-3.1.0 lib/unimatrix/configuration.rb
unimatrix-3.0.0 lib/unimatrix/configuration.rb