Sha256: 25f46011b62658b8a3fd4dfa03a3436f3864d418f627312340502b0fffa3a957

Contents?: true

Size: 532 Bytes

Versions: 7

Compression:

Stored size: 532 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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wikipedia-client-1.3.3 lib/wikipedia/configuration.rb
wikipedia-client-1.3.2 lib/wikipedia/configuration.rb
wikipedia-client-1.3.0 lib/wikipedia/configuration.rb
wikipedia-client-1.2.0 lib/wikipedia/configuration.rb
wikipedia-client-1.1.2 lib/wikipedia/configuration.rb
wikipedia-client-1.1.1 lib/wikipedia/configuration.rb
wikipedia-client-1.1.0 lib/wikipedia/configuration.rb