Sha256: f6f122ec85894955a2314e4851e1b154436b772005979c2c8bbdf0fcce667edf

Contents?: true

Size: 986 Bytes

Versions: 6

Compression:

Stored size: 986 Bytes

Contents

require "infopark_component_cache/consistency_guard"

module InfoparkComponentCache
  # @author Tomasz Przedmojski <tomasz.przedmojski@infopark.de>
  #
  # @abstract
  # This abstract class enables the implementing classes
  # to access the cms and read the current state.
  #
  # It also provides the option to limit the object classes
  # used for lookup.
  class CmsStateGuard < ConsistencyGuard
    class << self
      # This parameter should be initialized to the root Obj
      # class of the project
      attr_accessor :obj_root_class
    end

    protected

    # This method implements scoping on the root Obj class
    # and additional constraints for limiting object classes
    # used for lookup
    def scoped_relation
      conditions = if options[:obj_classes].present?
                     { obj_class: options[:obj_classes] }
                   else
                     {}
                   end
      CmsStateGuard.obj_root_class.where(conditions)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
infopark_component_cache-5.0.2 lib/infopark_component_cache/guards/cms_state_guard.rb
infopark_component_cache-5.0.1 lib/infopark_component_cache/guards/cms_state_guard.rb
infopark_component_cache-4.2.0 lib/infopark_component_cache/guards/cms_state_guard.rb
infopark_component_cache-4.1.0 lib/infopark_component_cache/guards/cms_state_guard.rb
infopark_component_cache-4.0.1 lib/infopark_component_cache/guards/cms_state_guard.rb
infopark_component_cache-4.0.0 lib/infopark_component_cache/guards/cms_state_guard.rb