Sha256: 91003e2b6c83c40a4eeffeb5ec351a9993a7fa08913c9e6b6da4f4a17f858f74

Contents?: true

Size: 1.41 KB

Versions: 52

Compression:

Stored size: 1.41 KB

Contents

module Appfuel
  module Application
    module ContainerClassRegistration
      # All handlers are automatically registered into the application
      # container which allows them to easily be retrieved for execution.
      # The ContainerKey mixin handles converting ruby class namespaces to
      # container key, so we simply need to obtain the qualified namespace
      # key for this class extending this, that does not belong to appfuel.
      #
      # types of classes:
      #   repositories
      #   db
      #   domains
      #
      #   features.repositories.key
      # @param klass [Class] the handler class that is inheriting this
      # @return [Boolean]
      def stage_class_for_registration(klass)
        if !klass.respond_to?(:register_class?) || !klass.register_class?
          return false
        end

        unless klass.respond_to?(:container_root_name)
          fail "#{klass} must implement :container_root_name"
        end
        root = klass.container_root_name
        return false if root == 'appfuel'

        container = Appfuel.app_container(klass.container_root_name)
        container[:auto_register_classes] << klass
      end

      def disable_class_registration
        @is_class_registration = false
      end

      def enable_class_registration
        @is_class_registration = true
      end

      def register_class?
        @is_class_registration ||= true
      end

    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
appfuel-0.7.0 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.16 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.15 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.14 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.13 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.12 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.11 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.10 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.9 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.8 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.7 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.6 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.5 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.4 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.3 lib/appfuel/application/container_class_registration.rb
appfuel-0.6.1 lib/appfuel/application/container_class_registration.rb
appfuel-0.5.16 lib/appfuel/application/container_class_registration.rb
appfuel-0.5.15 lib/appfuel/application/container_class_registration.rb
appfuel-0.5.14 lib/appfuel/application/container_class_registration.rb
appfuel-0.5.13 lib/appfuel/application/container_class_registration.rb