lib/gendered.rb in gendered-0.0.7 vs lib/gendered.rb in gendered-0.0.8

- old
+ new

@@ -1,12 +1,39 @@ -require 'bigdecimal' +require "bigdecimal" require "http" require "gendered/version" require "gendered/name" require "gendered/name_list" require "gendered/guesser" module Gendered + GenderedError = Class.new(StandardError) + class RateLimitError < GenderedError + attr_reader :limit, :remaining, :reset + def initialize(message, limit, remaining, reset) + super(message) + @limit = limit + @remaining = remaining + @reset = reset + end + end + + class Config < Struct.new(:apikey, :country_id, :language_id, :connection) + def merge(other) + hash = respond_to?(:to_h) ? to_h : Hash[each_pair.to_a] + hash.merge!(other) + hash.reject! { |k,v| v.nil? } + end + end + + def self.configure + raise ArgumentError, "configuration block required" unless block_given? + yield config + end + + def self.config + @config ||= Config.new + end end