Class: Hanami::CLI::Generators::App::Provider Private
- Inherits:
-
Object
- Object
- Hanami::CLI::Generators::App::Provider
- Defined in:
- lib/hanami/cli/generators/app/provider.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #call(key:, namespace:, base_path:, force: false, **_opts) ⇒ Object private
-
#initialize(fs:, inflector:, out: $stdout) ⇒ Provider
constructor
private
A new instance of Provider.
Constructor Details
#initialize(fs:, inflector:, out: $stdout) ⇒ Provider
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Provider.
9 10 11 12 13 |
# File 'lib/hanami/cli/generators/app/provider.rb', line 9 def initialize(fs:, inflector:, out: $stdout) @fs = fs @inflector = inflector @out = out end |
Instance Method Details
#call(key:, namespace:, base_path:, force: false, **_opts) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hanami/cli/generators/app/provider.rb', line 15 def call(key:, namespace:, base_path:, force: false, **_opts) name = inflector.underscore(key) registrar = if base_path == "app" "Hanami.app" else "#{inflector.camelize(namespace)}::Slice" end base_path = nil if base_path == "app" # Providers live in config/, not app/ path = fs.join(*[base_path, "config", "providers", "#{name}.rb"].compact) fs.create(path, file_contents(registrar, name), force:) end |