lib/mongoid/orderable.rb in mongoid_orderable-0.9.1 vs lib/mongoid/orderable.rb in mongoid_orderable-1.0.0

- old
+ new

@@ -1,23 +1,20 @@ module Mongoid::Orderable extend ActiveSupport::Concern - included do - orderable - end - module ClassMethods def orderable options = {} configuration = { :column => :position, + :index => true, :scope => nil } - configuration.update options if options.is_a?(Hash) - field configuration[:column], :type => Integer - index configuration[:column] - + configuration.merge! options if options.is_a?(Hash) configuration[:scope] = "#{configuration[:scope]}_id".to_sym if configuration[:scope].is_a?(Symbol) && configuration[:scope].to_s !~ /_id$/ + + field configuration[:column], :type => Integer + index configuration[:column] if configuration[:index] case configuration[:scope] when Symbol then scope :orderable_scope, lambda { |document| where(configuration[:scope] => document.send(configuration[:scope])) } when Proc then