Module: DbCharmer::ActionController::ForceSlaveReads::ClassMethods
- Defined in:
- lib/db_charmer/action_controller/force_slave_reads.rb
Constant Summary collapse
- @@db_charmer_force_slave_reads_actions =
{}
Instance Method Summary collapse
- #force_slave_reads(params = {}) ⇒ Object
- #force_slave_reads_action?(name = nil) ⇒ Boolean
- #force_slave_reads_options ⇒ Object
Instance Method Details
#force_slave_reads(params = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/db_charmer/action_controller/force_slave_reads.rb', line 7 def force_slave_reads(params = {}) @@db_charmer_force_slave_reads_actions[self.name] = { :except => params[:except] ? [*params[:except]].map(&:to_s) : [], :only => params[:only] ? [*params[:only]].map(&:to_s) : [] } end |
#force_slave_reads_action?(name = nil) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/db_charmer/action_controller/force_slave_reads.rb', line 18 def force_slave_reads_action?(name = nil) name = name.to_s = # If no options were defined for this controller, all actions are not forced to use slaves return false unless # Actions where force_slave_reads mode was turned off return false if [:except].include?(name) # Only for these actions force_slave_reads was turned on return [:only].include?(name) if [:only].any? # If :except is not empty, we're done with the checks and rest of the actions are should force slave reads # Otherwise, all the actions are not in force_slave_reads mode [:except].any? end |
#force_slave_reads_options ⇒ Object
14 15 16 |
# File 'lib/db_charmer/action_controller/force_slave_reads.rb', line 14 def @@db_charmer_force_slave_reads_actions[self.name] end |