lib/collectionadapters/array_sequel.rb in collectionadapters-0.2.0 vs lib/collectionadapters/array_sequel.rb in collectionadapters-0.3.0

- old
+ new

@@ -1,9 +1,10 @@ module CollectionAdapters class ArraySequel def initialize model:, column: - @model = model + @ds = model + @model = model.kind_of?(Sequel::Dataset) ? @ds.model : @ds @col = column.to_sym end def << val @model.new.set(@col => val).save @@ -22,18 +23,16 @@ def include? key @model[@col => key] != nil end def shift - @model.db.transaction do - if ob = @model.for_update.first + @ds.db.transaction do + if ob = @ds.for_update.first v = ob.values[@col] return v if ob.delete raise Sequel::rollback end end nil end end end - -