lib/ardb/default_order_by.rb in ardb-0.28.3 vs lib/ardb/default_order_by.rb in ardb-0.29.0

- old
+ new

@@ -1,25 +1,19 @@ -require 'much-plugin' +require "much-plugin" module Ardb - module DefaultOrderBy include MuchPlugin DEFAULT_ATTRIBUTE = :order_by DEFAULT_SCOPE_PROC = proc{ self.class.scoped } plugin_included do - extend ClassMethods - include InstanceMethods - @ardb_default_order_by_config = {} - end - module ClassMethods - + plugin_class_methods do def default_order_by(options = nil) options ||= {} @ardb_default_order_by_config.merge!({ :attribute => options[:attribute] || DEFAULT_ATTRIBUTE, @@ -30,15 +24,13 @@ end def ardb_default_order_by_config @ardb_default_order_by_config end - end - module InstanceMethods - + plugin_instance_methods do private def reset_order_by attr_name = self.class.ardb_default_order_by_config[:attribute] scope_proc = self.class.ardb_default_order_by_config[:scope_proc] @@ -50,10 +42,8 @@ def ardb_default_order_by attr_name = self.class.ardb_default_order_by_config[:attribute] reset_order_by if self.send(attr_name).to_s.empty? true end - end - end end