Class: Mongoid::Orderable::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/orderable/configuration.rb

Constant Summary collapse

CONFIG_OPTIONS =
%w(column scope foreign_key inherited base index default).map(&:to_sym)
FIELD_OPTIONS =
%w(as).map(&:to_sym)
VALID_OPTIONS =
CONFIG_OPTIONS + FIELD_OPTIONS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, options = {}) ⇒ Configuration

Returns a new instance of Configuration.



11
12
13
14
15
16
# File 'lib/mongoid/orderable/configuration.rb', line 11

def initialize(parent, options = {})
  @orderable_class = parent
  set_options(options)
  set_field_options
  set_orderable_scope
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/mongoid/orderable/configuration.rb', line 9

def options
  @options
end

#orderable_classObject (readonly)

Returns the value of attribute orderable_class.



9
10
11
# File 'lib/mongoid/orderable/configuration.rb', line 9

def orderable_class
  @orderable_class
end

Class Method Details

.build(parent, options = {}) ⇒ Object



26
27
28
# File 'lib/mongoid/orderable/configuration.rb', line 26

def self.build(parent, options = {})
  new(parent, options).options
end

Instance Method Details

#default_configurationObject



18
19
20
21
22
23
24
# File 'lib/mongoid/orderable/configuration.rb', line 18

def default_configuration
  { :column => :position,
    :index  => true,
    :scope  => nil,
    :base   => 1,
    :field_opts => { :type => Integer }}
end