module ConstantTableSaver::ClassMethods
Public Instance Methods
relation()
click to toggle source
Calls superclass method
# File lib/constant_table_saver.rb, line 57 def relation super.tap do |s| class << s # we implement find_some here because we'd have to use partial string matching to catch # this case in find_by_sql, which would be ugly. (we do the other cases in find_by_sql # because it's simpler & the only place to catch things like association find queries.) def find_some(ids) return super if @values.present? # special cases such as offset and limit ids.collect {|id| find_one(id)} end end end end
reset_constant_record_cache!()
click to toggle source
Resets the cached records. Remember that this only affects this process, so while this is useful for running tests, it's unlikely that you can use this in production - you would need to call it on every Rails instance on every Rails server. Don't use this plugin on if the table isn't really constant!
# File lib/constant_table_saver.rb, line 52 def reset_constant_record_cache! @constant_record_methods.each {|method_id| (class << self; self; end;).send(:remove_method, method_id)} if @constant_record_methods @cached_records = @cached_records_by_id = @constant_record_methods = @cached_blank_scope = @find_by_sql = nil end