def cattr_get_and_setter(*attrs)
      attrs.each do |attr|
        cattr_accessor attr
        singleton_class.instance_eval do
          alias_method "#{attr}_old_get".to_sym, attr
          define_method attr do |*args, &blk|
            if args.size > 0
              send("#{attr}=", *args)
            elsif blk != nil
              send("#{attr}=", blk)
            else
              send("#{attr}_old_get")
            end
          end
        end
      end
    end
def cattr_get_and_setter(*attrs)
      attrs.each do |attr|
        cattr_accessor attr
        singleton_class.instance_eval do
          alias_method "#{attr}_old_get".to_sym, attr
          define_method attr do |*args, &blk|
            if args.size > 0
              send("#{attr}=", *args)
            elsif blk != nil
              send("#{attr}=", blk)
            else
              send("#{attr}_old_get")
            end
          end
        end
      end
    end
Creates a DSL-friendly set-and-getter method. The method, when called with
 no arguments, acts as a getter. When called with arguments, it acts as a
 setter. Uses class instance variables - this is not for generating
 instance methods.

 @example
   class A
     cattr_get_and_setter :type
   end
   class B < A
     type :silly
   end
   p B.type  # => :silly