Module: Polist::Builder::ClassMethods

Defined in:
lib/polist/builder.rb

Instance Method Summary collapse

Instance Method Details

#build(*args) ⇒ Object



27
28
29
# File 'lib/polist/builder.rb', line 27

def build(*args)
  build_klass(*args).new(*args)
end

#build_klass(*args) ⇒ Object

Recursively runs class builders on class until no builders on that class found or some builder returns the class itself



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/polist/builder.rb', line 15

def build_klass(*args)
  klass = self

  loop do
    new_klass = klass.build!(klass, *args)
    break if new_klass == klass
    klass = new_klass
  end

  klass
end