Top Level Namespace

Defined Under Namespace

Modules: BlueprintComponents, Utils Classes: Blueprint

Instance Method Summary collapse

Instance Method Details

#blueprint(*args, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/blueprint.rb', line 5

def blueprint(*args, &block)
  blueprint_def = args.last.is_a?(Hash) ? args.pop : {}

  if blueprint_def.empty?
    blueprint_def[:label] = args.pop
  end
  
  if blueprint_def[:type]
    blueprint_def[:item_type] = blueprint_def.delete(:type)
  end

  blueprint = Blueprint.new(blueprint_def)

  if block_given?
    yield blueprint
  end

  blueprint
end