Class: Polist::Builder::Builders

Inherits:
Array
  • Object
show all
Defined in:
lib/polist/builder.rb

Instance Method Summary collapse

Instance Method Details

#<<(proc) ⇒ Object



20
21
22
23
# File 'lib/polist/builder.rb', line 20

def <<(proc)
  wrapped_proc = -> (ctx, *args, **kwargs) { ctx.instance_exec(*args, **kwargs, &proc) }
  super(wrapped_proc)
end

#call(context, *args, **kwargs) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/polist/builder.rb', line 12

def call(context, *args, **kwargs)
  each do |block|
    klass = block.call(context, *args, **kwargs) and return klass
  end

  context
end