lib/mongoid/orderable.rb in mongoid_orderable-5.2.0 vs lib/mongoid/orderable.rb in mongoid_orderable-6.0.0
- old
+ new
@@ -1,20 +1,29 @@
-module Mongoid::Orderable
- extend ActiveSupport::Concern
-
- included do
- include Mongoid::Orderable::Helpers
- include Mongoid::Orderable::Callbacks
- include Mongoid::Orderable::Movable
- include Mongoid::Orderable::Listable
-
- class_attribute :orderable_configurations
- end
-
- module ClassMethods
- def orderable(options = {})
- configuration = Mongoid::Orderable::Configuration.build(self, options)
-
- Mongoid::Orderable::OrderableClass.setup(self, configuration)
- end
- end
-end
+# frozen_string_literal: true
+
+module Mongoid
+ module Orderable
+ MUTEX = Mutex.new
+
+ class << self
+ def configure
+ yield(config) if block_given?
+ end
+
+ def config
+ @config || MUTEX.synchronize { @config = ::Mongoid::Orderable::Configs::GlobalConfig.new }
+ end
+ end
+
+ extend ActiveSupport::Concern
+
+ included do
+ class_attribute :orderable_configs
+ end
+
+ class_methods do
+ def orderable(options = {})
+ Mongoid::Orderable::Installer.new(self, options).setup
+ end
+ end
+ end
+end