Class: ActiveRecord::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/standby/active_record/relation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#standby_targetObject

Returns the value of attribute standby_target.



3
4
5
# File 'lib/standby/active_record/relation.rb', line 3

def standby_target
  @standby_target
end

Instance Method Details

#calculate(*args) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/standby/active_record/relation.rb', line 20

def calculate(*args)
  if standby_target
    Standby.on_standby(standby_target) { calculate_without_standby(*args) }
  else
    calculate_without_standby(*args)
  end
end

#calculate_without_standbyObject

Supports queries like User.on_standby.count



18
# File 'lib/standby/active_record/relation.rb', line 18

alias_method :calculate_without_standby, :calculate

#exec_queriesObject



8
9
10
11
12
13
14
# File 'lib/standby/active_record/relation.rb', line 8

def exec_queries
  if standby_target
    Standby.on_standby(standby_target) { exec_queries_without_standby }
  else
    exec_queries_without_standby
  end
end

#exec_queries_without_standbyObject

Supports queries like User.on_standby.to_a



6
# File 'lib/standby/active_record/relation.rb', line 6

alias_method :exec_queries_without_standby, :exec_queries