Class: Muack::Block

Inherits:
Struct
  • Object
show all
Defined in:
lib/muack/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, context = nil) ⇒ Block

Returns a new instance of Block.



4
5
6
# File 'lib/muack/block.rb', line 4

def initialize block, context=nil
  super
end

Instance Attribute Details

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



3
4
5
# File 'lib/muack/block.rb', line 3

def block
  @block
end

#contextObject

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



3
4
5
# File 'lib/muack/block.rb', line 3

def context
  @context
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
# File 'lib/muack/block.rb', line 8

def call(...)
  if context
    context.instance_exec(...)
  else
    block.call(...)
  end
end