Class: ActiveRecord::Relation
- Inherits:
-
Object
- Object
- ActiveRecord::Relation
- Defined in:
- lib/standby/active_record/relation.rb
Instance Attribute Summary collapse
-
#standby_target ⇒ Object
Returns the value of attribute standby_target.
Instance Method Summary collapse
- #calculate(*args) ⇒ Object
-
#calculate_without_standby ⇒ Object
Supports queries like User.on_standby.count.
- #exec_queries ⇒ Object
-
#exec_queries_without_standby ⇒ Object
Supports queries like User.on_standby.to_a.
Instance Attribute Details
#standby_target ⇒ Object
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_standby ⇒ Object
Supports queries like User.on_standby.count
18 |
# File 'lib/standby/active_record/relation.rb', line 18 alias_method :calculate_without_standby, :calculate |
#exec_queries ⇒ Object
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_standby ⇒ Object
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 |