Sha256: e15a0599131c6e463249bdd8951d86d8c9ccb52c0de5a049409c0a41d7ccd945
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
module Appfuel module Feature # Run a given feature's initializers. Each feature can declare any number # of initializers just as the application does. This allow dependencies # and vendor code to be initialized only when the feature is used. class Initializer # Ensure the correct namespaces are registered so that the initializer # dsl will work and then require the feature and run its intializers # unless instructed not too. Initializers are only run once. # # @param name [String] name of the feature as found in the container # @param container [Dry::Container] application container # @return [Boolean] def call(name, container) name = name.to_s.underscore feature_key = "features.#{name}" unless container.key?(feature_key) Appfuel.setup_container_dependencies(feature_key, container) end unless require_feature_disabled?(container, feature_key) require "#{container[:features_path]}/#{name}" end return false if initialized?(container, feature_key) Appfuel.run_initializers(feature_key, container) true end private def require_feature_disabled?(container, feature_key) disable_key = "#{feature_key}.disable_require" container.key?(disable_key) && container[disable_key] == true end def initialized?(container, feature_key) init_key = "#{feature_key}.initialized" container.key?(init_key) && container[init_key] == true end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
appfuel-0.2.3 | lib/appfuel/feature/initializer.rb |
appfuel-0.2.2.pre.alpha.pre.140 | lib/appfuel/feature/initializer.rb |
appfuel-0.2.0 | lib/appfuel/feature/initializer.rb |