Method: Serial::Builder#exec

Defined in:
lib/serial/builder.rb

#exec(*args) {|self, *args| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes a block in the configured context, if there is one, otherwise using regular closure scoping.

Yields:

  • (self, *args)

Yield Parameters:

  • self (Builder)

    passes in self as the first parameter.

  • *args

    superflous arguments are passed to the block.

[View source]

30
31
32
33
34
35
36
37
38
# File 'lib/serial/builder.rb', line 30

def exec(*args, &block)
  if @context
    @context.instance_exec(self, *args, &block)
  elsif block
    block.call(self, *args)
  else
    raise ArgumentError, "no serializer block given"
  end
end