Class: DSL::Maker::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl/maker.rb

Overview

This is the base class for all DSL-parsing classes.

Instance Method Summary collapse

Instance Method Details

#default(method_name, args, position = 0) ⇒ Object

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) (defaults to: 0)

    The index in args to work with, default 0.

Returns:

  • nil



22
23
24
25
26
27
28
# File 'lib/dsl/maker.rb', line 22

def default(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