Sha256: 9f2db16c759ccb02fc794ceeef0c5757fcd3f27c041a3fcc92bbfe4aa4b91d9a

Contents?: true

Size: 612 Bytes

Versions: 3

Compression:

Stored size: 612 Bytes

Contents

class DRG::Decorators::SexpDecorator < DelegateClass(Sexp)
  def each_sexp_condition
    return enum_for(__method__) unless block_given?
    yielded = []
    each_sexp do |exp|
      if exp.first == :if
        yield exp
        yielded << exp
      else
        nested_sexp = exp.enum_for(:deep_each).select { |s| s.first == :if }
        nested_sexp.each do |sexp|
          if yielded.find { |x| x.object_id == sexp.object_id or x.enum_for(:deep_each).find { |xx| xx.object_id == sexp.object_id } }.nil?
            yield sexp
            yielded << sexp
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
drg-0.15.6 lib/drg/decorators/sexp_decorator.rb
drg-0.15.5 lib/drg/decorators/sexp_decorator.rb
drg-0.15.4 lib/drg/decorators/sexp_decorator.rb