Module: Liszt
- Defined in:
- lib/liszt.rb,
lib/liszt/version.rb,
lib/liszt/redis_list.rb,
lib/liszt/instantizeable.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods, Instantizeable Classes: RedisList
Constant Summary collapse
- VERSION =
"0.0.7"
Instance Method Summary collapse
-
#acts_as_liszt(options = {}) ⇒ Object
Set up a scoped ordering for this model.
Instance Method Details
#acts_as_liszt(options = {}) ⇒ Object
Set up a scoped ordering for this model.
Liszt currently only supports one type of ranking per model. It also doesn't currently support re-sorting lists when a scope changes. The assumption is that attributes used as scopes won't change after creation.
The other major limitation at the moment is that scopes can't be nil. If a record has nil for a scope value, its associated list will never have any items in it.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/liszt.rb', line 25 def acts_as_liszt( = {}) extend Instantizeable extend ClassMethods include InstanceMethods # Make "instantized" versions of the class methods. ClassMethods.instance_methods.each do |method| instantize method end .reverse_merge! :conditions => {}, :scope => [] @liszt_conditions = [:conditions] @liszt_scope = Array([:scope]).sort_by(&:to_s) @liszt_query = nil @liszt_sort_by = [:sort_by] @liszt_append_new_items = [:append_new_items] end |