Sha256: 537fd69f1686d8c5b2482308b097e0eef01f1e8b0ce4de5cffa11790ae39ca07

Contents?: true

Size: 537 Bytes

Versions: 5

Compression:

Stored size: 537 Bytes

Contents

require 'singleton'

module Wikipedia
  class Configuration
    include Singleton

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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wikipedia-client-1.6.3 lib/wikipedia/configuration.rb
wikipedia-client-1.6.2 lib/wikipedia/configuration.rb
wikipedia-client-1.6.1 lib/wikipedia/configuration.rb
wikipedia-client-1.5.0 lib/wikipedia/configuration.rb
wikipedia-client-1.4.0 lib/wikipedia/configuration.rb