joshuabowers / opium

An Object Parse.com Mapping technology for defining models.
MIT License
1 stars 0 forks source link

Provide a lock/unlock mechanism for Queryable/Criteria #9

Closed joshuabowers closed 9 years ago

joshuabowers commented 9 years ago

This would help support #8:

Perhaps these would be better named cache and uncache?

Motivation: write a criteria which can be enumerated several times over without needing to re-execute the network query each time, nor for having to throw out context. Useful for providing more data to kaminari.

class Game
  field :price, type: Float
  scope :cheaper_than, ->( cost ) { lte( price: cost ) }
end

cheap_games = Game.lock.cheaper_than( 10 )

cheap_games.count # => 5
cheap_games.to_a # <#Game price: 5.99> ...