Class: MethodMatching::ExtendableBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/method_matching/extendable_block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&definition) ⇒ ExtendableBlock

Returns a new instance of ExtendableBlock.



5
6
7
# File 'lib/method_matching/extendable_block.rb', line 5

def initialize(&definition)
  @definition = definition
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



3
4
5
# File 'lib/method_matching/extendable_block.rb', line 3

def block
  @block
end

Instance Method Details

#block_given?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/method_matching/extendable_block.rb', line 13

def block_given?
  !!@block
end

#call(*args) ⇒ Object



9
10
11
# File 'lib/method_matching/extendable_block.rb', line 9

def call(*args)
  instance_exec(*args, &@definition)
end