module Torque::PostgreSQL::Collector

Public Class Methods

new(*args) click to toggle source

This classe helps to collect data in different ways. Used to configure auxiliary statements

# File lib/torque/postgresql/collector.rb, line 9
def self.new(*args)
  klass = Class.new

  args.flatten!
  args.compact!

  klass.module_eval do
    args.each do |attribute|
      define_method attribute do |*args|
        if args.empty?
          instance_variable_get("@#{attribute}")
        elsif args.size > 1
          instance_variable_set("@#{attribute}", args)
        else
          instance_variable_set("@#{attribute}", args.first)
        end
      end
      alias_method "#{attribute}=", attribute
    end
  end

  klass
end