Sha256: ad9b7733de4dc00a5db27d1d2f0145c89c6444c088dd0d0db8e629900a6f2ee1

Contents?: true

Size: 882 Bytes

Versions: 22

Compression:

Stored size: 882 Bytes

Contents

module Toolhound
  module Configurable

    # attr_accessor :auto_paginate, :per_page
    attr_writer :dataserver, :port, :username, :password

    # Define static methods
    class << self

      def keys
        @keys ||= [
          :dataserver,
          :port,
          :username,
          :password
        ]
      end
    end

    # Set configuration options using a block
    def configure
      yield self
    end

    # Reset configuration options to default values
    def reset!
      Toolhound::Configurable.keys.each do |key|
        instance_variable_set(:"@#{key}", Toolhound::Default.options[key])
      end
      self
    end
    alias setup reset!

    # def api_endpoint
    #   File.join(@api_endpoint, "")
    # end

    def options
      Hash[Toolhound::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}]
    end

  private



  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
toolhound-ruby-1.0.5 lib/toolhound-ruby/configurable.rb
toolhound-ruby-1.0.4 lib/toolhound-ruby/configurable.rb