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
if
unless
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.



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

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.



23
24
25
# File 'lib/mongoid/orderable/configs/field_config.rb', line 23

def options
  @options
end

#orderable_classObject (readonly)

Returns the value of attribute orderable_class.



23
24
25
# File 'lib/mongoid/orderable/configs/field_config.rb', line 23

def orderable_class
  @orderable_class
end

Instance Method Details

#global_configObject



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

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