Sha256: f4a33e538e51a621cebbcc58b601dc2a476d266228ae6e6e1af5e22f6ab1345d

Contents?: true

Size: 516 Bytes

Versions: 2

Compression:

Stored size: 516 Bytes

Contents

class ModelSet
  class SetQuery < Query
    delegate :add!, :unshift!, :subtract!, :intersect!, :reorder!, :to => :set

    def anchor!(query)
      @set = query.ids.to_ordered_set
    end

    def set
      @set ||= [].to_ordered_set
    end

    def ids
      if limit
        set.limit(limit, offset)
      else
        set.clone
      end
    end
    
    def size
      if limit
        [count - offset, limit].min
      else
        count
      end
    end

    def count
      set.size
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ninjudd-model_set-0.10.0 lib/model_set/set_query.rb
ninjudd-model_set-0.9.2 lib/model_set/set_query.rb