Sha256: 498c9cc46e6dce28a9fbb7e3131229437e3394e184b1b113387ba51057a2250c

Contents?: true

Size: 846 Bytes

Versions: 3

Compression:

Stored size: 846 Bytes

Contents

module Patentscope

  class << self
    attr_accessor :configuration

    def configure
      self.configuration ||= Configuration.new
      yield(configuration) if block_given?
    end

    def configure_from_env
      if self.configuration
        return false
      else
        self.configuration = Configuration.new
        self.configuration.username = ENV['PATENTSCOPE_WEBSERVICE_USERNAME']
        self.configuration.password = ENV['PATENTSCOPE_WEBSERVICE_PASSWORD']
        return true
      end
    end

    def configured?
      (configuration && configuration.username && configuration.password)? true : false
    end

    def reset_configuration
      self.configuration = nil
    end
  end

  class Configuration
    attr_accessor :username, :password

    def initialize
      @username = ''
      @password = ''
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
patentscope-0.0.5 lib/patentscope/configuration.rb
patentscope-0.0.4 lib/patentscope/configuration.rb
patentscope-0.0.2 lib/patentscope/configuration.rb