Top Level Namespace

Defined Under Namespace

Modules: DSL

Instance Method Summary collapse

Instance Method Details

#defaultObject

A helper method for handling defaults from args easily.

Parameters:

  • method_name (String)

    The name of the attribute being defaulted.

  • args (Array)

    The arguments provided to the block.

  • position (Integer)

    The index in args to work with, default 0.

Returns:

  • nil



458
459
460
461
462
463
464
# File 'lib/dsl/maker.rb', line 458

DSL::Maker.add_helper(:default) do |method_name, args, position=0|
  method = method_name.to_sym
  if args.length >= (position + 1) && !self.send(method)
    self.send(method, args[position])
  end
  return
end