Module: Scorpion::Rails::ActiveRecord::Relation

Includes:
Method, Stinger
Defined in:
lib/scorpion/rails/active_record/relation.rb

Overview

Make sure that all models return by the relation inherit the relation’s scorpion.

Instance Method Summary collapse

Methods included from Method

#scorpion, #scorpion_hunt

Methods included from Stinger

#sting!, wrap

Instance Method Details

#spawnObject

from ActiveRecord::SpawnMethods



46
47
48
# File 'lib/scorpion/rails/active_record/relation.rb', line 46

def spawn
  sting!( super )
end

#with_scorpion(scorpion) ⇒ Object

Elect to use a specific scorpion for all further operations in the chain.

Examples:


User.all.with_scorpion( scorpion ).where( ... )
User.with_scorpion( scorpion ).where( ... )


26
27
28
29
30
# File 'lib/scorpion/rails/active_record/relation.rb', line 26

def with_scorpion( scorpion )
  spawn.tap do |other|
    other.send :scorpion=, scorpion
  end
end