Module: Ardb::DefaultOrderBy::ClassMethods

Defined in:
lib/ardb/default_order_by.rb

Instance Method Summary collapse

Instance Method Details

#ardb_default_order_by_configObject



32
33
34
# File 'lib/ardb/default_order_by.rb', line 32

def ardb_default_order_by_config
  @ardb_default_order_by_config
end

#default_order_by(options = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/ardb/default_order_by.rb', line 21

def default_order_by(options = nil)
  options ||= {}

  @ardb_default_order_by_config.merge!({
    :attribute  => options[:attribute] || DEFAULT_ATTRIBUTE,
    :scope_proc => options[:scope]     || DEFAULT_SCOPE_PROC
  })

  before_validation :ardb_default_order_by, :on => :create
end