Sha256: e8b30540bee07d8bb113b0bcd8afbd2cac1f71fc96ccd3b1323a9bb10bbed7fc

Contents?: true

Size: 495 Bytes

Versions: 11

Compression:

Stored size: 495 Bytes

Contents

require 'singleton'

module Wikipedia
  class Configuration
    include Singleton

    def self.directives(*directives)
      directives.each do |directive|
        define_method directive do |*args|
          return instance_variable_get("@#{directive}") if args.empty?

          instance_variable_set("@#{directive}", args.first)
        end
      end
    end

    def self.[](directive)
      instance.send(directive)
    end

    directives :protocol, :domain, :path, :user_agent
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wikipedia-client-1.14.0 lib/wikipedia/configuration.rb
wikipedia-client-1.13.0 lib/wikipedia/configuration.rb
wikipedia-client-1.12.0 lib/wikipedia/configuration.rb
wikipedia-client-1.11.0 lib/wikipedia/configuration.rb
wikipedia-client-1.10.0 lib/wikipedia/configuration.rb
wikipedia-client-1.9.1 lib/wikipedia/configuration.rb
wikipedia-client-1.9.0 lib/wikipedia/configuration.rb
wikipedia-client-1.8.0 lib/wikipedia/configuration.rb
wikipedia-client-1.7.1 lib/wikipedia/configuration.rb
wikipedia-client-1.7.0 lib/wikipedia/configuration.rb
wikipedia-client-1.6.4 lib/wikipedia/configuration.rb