Module: XFTP::DSL::BlockEvaluator

Included in:
Session::Base
Defined in:
lib/xftp/dsl/block_evaluator.rb

Overview

Gives the target class an ability to expose both DSL design patterns. It yields self as a block argument if arity of the given block takes exactly 1 argument, otherwise it simply evaluates the given block of the target class instance (see BasicObject#instance_eval)

Instance Method Summary collapse

Instance Method Details

#evaluate(&callback) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/xftp/dsl/block_evaluator.rb', line 8

def evaluate(&callback)
  return unless block_given?
  if callback.arity == 1
    yield self
  else
    instance_eval(&callback)
  end
end