Sha256: f4ca46331af47e2523810d24d05f2d4a0884f54f55c4a945ccb7749db78d2316

Contents?: true

Size: 607 Bytes

Versions: 10

Compression:

Stored size: 607 Bytes

Contents

module XFTP
  # Contains helper classes and modules to simplify building a DSL
  module DSL
    # 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)
    module BlockEvaluator
      def evaluate(&callback)
        return unless block_given?
        if callback.arity == 1
          yield self
        else
          instance_eval(&callback)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
xftp-0.5.0 lib/xftp/dsl/block_evaluator.rb
xftp-0.4.4 lib/xftp/dsl/block_evaluator.rb
xftp-0.4.3 lib/xftp/dsl/block_evaluator.rb
xftp-0.4.2 lib/xftp/dsl/block_evaluator.rb
xftp-0.4.1 lib/xftp/dsl/block_evaluator.rb
xftp-0.3.3 lib/xftp/dsl/block_evaluator.rb
xftp-0.3.1 lib/xftp/dsl/block_evaluator.rb
xftp-0.2.1.pre.alpha lib/xftp/dsl/block_evaluator.rb
xftp-0.2.0.pre.alpha lib/xftp/dsl/block_evaluator.rb
xftp-0.1.0.pre.alpha lib/xftp/dsl/block_evaluator.rb