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.



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

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.



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

def options
  @options
end

#orderable_classObject (readonly)

Returns the value of attribute orderable_class.



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

def orderable_class
  @orderable_class
end

Class Method Details

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



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

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

Instance Method Details

#default_configurationObject



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

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