Module: Elasticated::Mixins::BlockEvaluation

Instance Method Summary collapse

Instance Method Details

#evaluate(block = nil, obj = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/elasticated/mixins/block_evaluation.rb', line 5

def evaluate(block=nil, obj=nil)
  return unless block
  obj ||= self
  if block.parameters.empty?
    obj.instance_exec &block
  else
    block.call obj
  end
end