Sha256: 7ca5a2d728060733df23367be2cc8f56e745cf69010c318e48107320cc5c1d05

Contents?: true

Size: 698 Bytes

Versions: 5

Compression:

Stored size: 698 Bytes

Contents

module DataMapper
  module Ambition
    module Query
      @@sexps = {}

      # TODO: spec and document this
      # @api semipublic
      def filter(negated = false, &block)
        # TODO: benchmark Marshal versus just building the sexp on demand

        # deep clone the sexp for multiple re-use
        sexp = Marshal.load(@@sexps[block.to_s] ||= Marshal.dump(block.to_sexp))

        processor = FilterProcessor.new(block.binding, model, negated)
        processor.process(sexp)

        merge(:conditions => processor.conditions)
      end
    end # module Query
  end # module Ambition
end # module DataMapper

require Pathname(__FILE__).dirname.expand_path / 'query' / 'filter_processor'

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dm-ambition-1.0.0 lib/dm-ambition/query.rb
dm-ambition-1.0.0.rc3 lib/dm-ambition/query.rb
dm-ambition-1.0.0.rc2 lib/dm-ambition/query.rb
dm-ambition-1.0.0.rc1 lib/dm-ambition/query.rb
dm-ambition-0.10.2 lib/dm-ambition/query.rb