Method: EachSQL#each

Defined in:
lib/each_sql/each_sql.rb

#each {|String| ... } ⇒ NilClass

Parses the buffer and enumerates through the executable blocks.

Yields:

  • (String)

Returns:

  • (NilClass)


70
71
72
73
74
75
76
77
78
79
80
# File 'lib/each_sql/each_sql.rb', line 70

def each
  return enum_for(:each) unless block_given?

  result = shift
  sqls   = (result[:sqls] + result[:leftover]).
            map { |sql| strip_sql(sql) }.
            reject(&:empty?)
  sqls.each do |sql|
    yield sql
  end
end