def def_add(name, options)
      old_verbose, $VERBOSE = $VERBOSE, false # skip method redefinition warning
      define_singleton_method name do |*args, &block|
        defaults = options.fetch(:defaults, {})
        klass    = options.fetch(:create)

        if args.last.instance_of?(Hash)
          args[-1] = defaults.merge(args[-1])
        else
          args << defaults
        end

        self.config = config.append_to(
          options.fetch(:append_to),
          klass.create(*args, &block)
        )
      end
    ensure
      $VERBOSE = old_verbose
    end
def def_add(name, options)
      old_verbose, $VERBOSE = $VERBOSE, false # skip method redefinition warning
      define_singleton_method name do |*args, &block|
        defaults = options.fetch(:defaults, {})
        klass    = options.fetch(:create)

        if args.last.instance_of?(Hash)
          args[-1] = defaults.merge(args[-1])
        else
          args << defaults
        end

        self.config = config.append_to(
          options.fetch(:append_to),
          klass.create(*args, &block)
        )
      end
    ensure
      $VERBOSE = old_verbose
    end
Generate a DSL method that creates a certain type of domain
 object, and adds it to a list on the config.

     def_add :fieldset, create: Fieldset, append_to: :fields

 This will generate a `fieldset` method, which will call
 `Fieldset.create`, and append the result to `config.fields`