Class: Mongoid::Orderable::Configs::FieldConfig

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

Constant Summary collapse

CONFIG_OPTIONS =
i[field
scope
foreign_key
inherited
base
index
default
use_transactions
transaction_max_retries
lock_collection].freeze
ALIASES =
{ column: :field }.freeze
FIELD_OPTIONS =
i[as].freeze
VALID_OPTIONS =
(CONFIG_OPTIONS | FIELD_OPTIONS).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of FieldConfig.



24
25
26
27
28
29
# File 'lib/mongoid/orderable/configs/field_config.rb', line 24

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/mongoid/orderable/configs/field_config.rb', line 21

def options
  @options
end

#orderable_classObject (readonly)

Returns the value of attribute orderable_class.



21
22
23
# File 'lib/mongoid/orderable/configs/field_config.rb', line 21

def orderable_class
  @orderable_class
end

Instance Method Details

#global_configObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/mongoid/orderable/configs/field_config.rb', line 31

def global_config
  cfg = Mongoid::Orderable.config
  { field: cfg.field,
    as: cfg.as,
    index: cfg.index,
    base: cfg.base,
    use_transactions: cfg.use_transactions,
    transaction_max_retries: cfg.transaction_max_retries,
    lock_collection: cfg.lock_collection }
end