Sha256: 51b918502fd955059baa542fccfa38fe6460280447f9b710c615316ad427862a

Contents?: true

Size: 557 Bytes

Versions: 9

Compression:

Stored size: 557 Bytes

Contents

class ModelSet
  class SetQuery < Query
    delegate :add!, :unshift!, :subtract!, :intersect!, :reorder!, :reverse!, :reverse_reorder!, :shuffle!, :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

9 entries across 9 versions & 2 rubygems

Version Path
ninjudd-model_set-0.10.5 lib/model_set/set_query.rb
model_set-1.1.3 lib/model_set/set_query.rb
model_set-1.1.2 lib/model_set/set_query.rb
model_set-1.1.1 lib/model_set/set_query.rb
model_set-1.1.0 lib/model_set/set_query.rb
model_set-1.0.0 lib/model_set/set_query.rb
model_set-0.11.1 lib/model_set/set_query.rb
model_set-0.11.0 lib/model_set/set_query.rb
model_set-0.10.6 lib/model_set/set_query.rb