Module: Appfuel::Application::ContainerClassRegistration

Defined in:
lib/appfuel/application/container_class_registration.rb

Instance Method Summary collapse

Instance Method Details

#disable_class_registrationObject



33
34
35
# File 'lib/appfuel/application/container_class_registration.rb', line 33

def disable_class_registration
  @is_class_registration = false
end

#enable_class_registrationObject



37
38
39
# File 'lib/appfuel/application/container_class_registration.rb', line 37

def enable_class_registration
  @is_class_registration = true
end

#register_class?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/appfuel/application/container_class_registration.rb', line 41

def register_class?
  @is_class_registration ||= true
end

#stage_class_for_registration(klass) ⇒ Boolean

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

Parameters:

  • klass (Class)

    the handler class that is inheriting this

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/appfuel/application/container_class_registration.rb', line 18

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