module DbCharmer::ActionController::ForceSlaveReads::ClassMethods
Public Instance Methods
force_slave_reads(params = {})
click to toggle source
# 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)
click to toggle source
# File lib/db_charmer/action_controller/force_slave_reads.rb, line 18 def force_slave_reads_action?(name = nil) name = name.to_s options = force_slave_reads_options # If no options were defined for this controller, all actions are not forced to use slaves return false unless options # Actions where force_slave_reads mode was turned off return false if options[:except].include?(name) # Only for these actions force_slave_reads was turned on return options[:only].include?(name) if options[: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 options[:except].any? end
force_slave_reads_options()
click to toggle source
# File lib/db_charmer/action_controller/force_slave_reads.rb, line 14 def force_slave_reads_options @@db_charmer_force_slave_reads_actions[self.name] end