Sha256: fd3eaf903120eb842289829e139603e0e626d93bf40452fc6bcb85237548a41a

Contents?: true

Size: 910 Bytes

Versions: 9

Compression:

Stored size: 910 Bytes

Contents

module DataMapper
  module Aggregates
    module Query
      def self.included(base)
        base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
          # FIXME: figure out a cleaner approach than AMC
          alias_method :assert_valid_fields_without_operator, :assert_valid_fields
          alias_method :assert_valid_fields, :assert_valid_fields_with_operator
        RUBY
      end

      def assert_valid_fields_with_operator(fields, unique)
        operators, fields = fields.partition { |f| f.kind_of?(DataMapper::Query::Operator) }

        operators.each do |operator|
          target = operator.target

          unless target == :all || @properties.include?(target)
            raise ArgumentError, "+options[:fields]+ entry #{target.inspect} does not map to a property in #{model}"
          end
        end

        assert_valid_fields_without_operator(fields, unique)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
ardm-aggregates-1.2.0 lib/dm-aggregates/query.rb
dm-aggregates-1.2.0 lib/dm-aggregates/query.rb
dm-aggregates-1.2.0.rc2 lib/dm-aggregates/query.rb
dm-aggregates-1.2.0.rc1 lib/dm-aggregates/query.rb
dm-aggregates-1.1.0 lib/dm-aggregates/query.rb
dm-aggregates-1.1.0.rc3 lib/dm-aggregates/query.rb
dm-aggregates-1.1.0.rc2 lib/dm-aggregates/query.rb
dm-aggregates-1.1.0.rc1 lib/dm-aggregates/query.rb
dm-aggregates-1.0.2 lib/dm-aggregates/query.rb