Class: Torikago::Configuration
- Inherits:
-
Object
- Object
- Torikago::Configuration
- Defined in:
- lib/torikago/configuration.rb,
sig/torikago.rbs
Overview
Stores module definitions declared by the host application. Other runtime objects treat this as the source of truth for module roots and boot options.
Defined Under Namespace
Classes: Definition
Instance Method Summary collapse
- #each_definition {|arg0| ... } ⇒ Object
- #fetch(name) ⇒ Definition
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #register(name, root:, entrypoint: nil, rails_engine: false, setup: nil, gemfile: nil) ⇒ Definition
- #registered?(name) ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 |
# File 'lib/torikago/configuration.rb', line 9 def initialize @definitions = Hash.new end |
Instance Method Details
#each_definition ⇒ Object #each_definition ⇒ Object
32 33 34 35 36 |
# File 'lib/torikago/configuration.rb', line 32 def each_definition(&block) return @definitions.each_value unless block @definitions.each_value(&block) end |
#fetch(name) ⇒ Definition
38 39 40 41 42 43 44 |
# File 'lib/torikago/configuration.rb', line 38 def fetch(name) normalized_name = name.to_sym @definitions.fetch(normalized_name) do raise KeyError, "module not registered: #{name}" end end |
#register(name, root:, entrypoint: nil, rails_engine: false, setup: nil, gemfile: nil) ⇒ Definition
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/torikago/configuration.rb', line 13 def register(name, root:, entrypoint: nil, rails_engine: false, setup: nil, gemfile: nil) if @definitions.key?(name.to_sym) raise ArgumentError, "module already registered: #{name}" end @definitions[name.to_sym] = Definition.new( name: name.to_sym, root: Pathname(root), entrypoint: entrypoint, rails_engine: rails_engine, setup: setup, gemfile: gemfile ) end |
#registered?(name) ⇒ Boolean
28 29 30 |
# File 'lib/torikago/configuration.rb', line 28 def registered?(name) @definitions.key?(name.to_sym) end |