lib/spontaneous/collections/entry_set.rb in spontaneous-0.2.0.beta1 vs lib/spontaneous/collections/entry_set.rb in spontaneous-0.2.0.beta2

- old
+ new

@@ -10,21 +10,13 @@ def initialize(owner, piece_store = []) @owner = owner @store = Hash.new { |hash, key| hash[key] = [] } (piece_store || []).each do |data| id = data[0] - entry = \ - if data.length == 2 - page = @owner._pieces.detect { |piece| piece.id == id } - if page - Spontaneous::PagePiece.new(@owner, page, data[1]) - else - nil - end - else - @owner._pieces.detect { |piece| piece.id == id } - end + entry = if (content = @owner._pieces.detect { |piece| piece.id == id }) + content.page? ? Spontaneous::PagePiece.new(@owner, content, data[1]) : content + end # if the piece/page has been deleted or is invisible # then we just want to silently skip it if entry box_id = entry.box_sid.to_s @store[box_id] << entry @@ -116,10 +108,10 @@ end set.freeze end def ==(set) - super or entries == set + super || (entries == set) end protected def concat(box_id, entries)