Sha256: cc8fc78b1d2fcafc0139e53777b69b78a352fe8d3c71abf1e5f2e38eed48d649

Contents?: true

Size: 984 Bytes

Versions: 34

Compression:

Stored size: 984 Bytes

Contents

module MongoModel
  class Scope
    module SpawnMethods
      def merge(scope)
        result = clone
        
        MULTI_VALUE_METHODS.each do |method|
          values = send(:"#{method}_values") + scope.send(:"#{method}_values")
          result.send(:"#{method}_values=", values.uniq)
        end
        
        SINGLE_VALUE_METHODS.each do |method|
          value = scope.send(:"#{method}_value")
          result.send(:"#{method}_value=", value) if value
        end
        
        result
      end
      
      def except(*exceptions)
        result = self.class.new(klass)
        
        MULTI_VALUE_METHODS.each do |method|
          result.send(:"#{method}_values=", send(:"#{method}_values")) unless exceptions.include?(method)
        end
        
        SINGLE_VALUE_METHODS.each do |method|
          result.send(:"#{method}_value=", send(:"#{method}_value")) unless exceptions.include?(method)
        end
        
        result
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
mongomodel-0.4.5 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.4.4 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.4.3 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.4.2 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.4.1 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.4.0 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.3.6 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.3.5 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.3.4 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.3.3 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.3.2 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.3.1 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.3.0 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.2.20 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.2.19 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.2.18 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.2.17 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.2.16 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.2.15 lib/mongomodel/support/scope/spawn_methods.rb
mongomodel-0.2.14 lib/mongomodel/support/scope/spawn_methods.rb