lib/kasket/write_mixin.rb in kasket-0.5.5 vs lib/kasket/write_mixin.rb in kasket-0.6.0

- old
+ new

@@ -1,7 +1,8 @@ module Kasket module WriteMixin + module ClassMethods def remove_from_kasket(ids) Array(ids).each do |id| Kasket.cache.delete(kasket_key_for_id(id)) end @@ -18,11 +19,11 @@ @kasket_key ||= new_record? ? nil : self.class.kasket_key_for_id(id) end def store_in_kasket if !readonly? && kasket_key - Kasket.cache.write(kasket_key, self) + Kasket.cache.write(kasket_key, @attributes) end end def kasket_keys attribute_sets = [attributes.symbolize_keys] @@ -33,16 +34,17 @@ end keys = [] self.class.kasket_indices.each do |index| keys += attribute_sets.map do |attribute_set| - self.class.kasket_key_for(index.map { |attribute| [attribute, attribute_set[attribute]]}) + key = self.class.kasket_key_for(index.map { |attribute| [attribute, attribute_set[attribute]]}) + index.include?(:id) ? key : [key, key + '/first'] end end - keys.uniq! - keys.map! {|key| [key, "#{key}/first"]} keys.flatten! + keys.uniq! + keys end def clear_kasket_indices kasket_keys.each do |key| Kasket.cache.delete(key)