Class: Hanami::CLI::Generators::App::RubyFile Private
- Inherits:
-
Object
- Object
- Hanami::CLI::Generators::App::RubyFile
- Defined in:
- lib/hanami/cli/generators/app/ruby_file.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.
Direct Known Subclasses
Instance Method Summary collapse
- #create(force: false) ⇒ Object private
- #fully_qualified_name ⇒ Object private
-
#initialize(fs:, inflector:, key:, namespace:, base_path:, extra_namespace: nil, auto_register: nil, requires: [], body: [], **_opts) ⇒ RubyFile
constructor
private
A new instance of RubyFile.
- #path ⇒ Object private
- #write ⇒ Object private
Constructor Details
#initialize(fs:, inflector:, key:, namespace:, base_path:, extra_namespace: nil, auto_register: nil, requires: [], body: [], **_opts) ⇒ RubyFile
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 RubyFile.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hanami/cli/generators/app/ruby_file.rb', line 11 def initialize( fs:, inflector:, key:, namespace:, base_path:, extra_namespace: nil, auto_register: nil, requires: [], body: [], **_opts ) @fs = fs @inflector = inflector @key_segments = key.split(KEY_SEPARATOR).map { |segment| inflector.underscore(segment) } @namespace = namespace @base_path = base_path @extra_namespace = extra_namespace&.downcase @auto_register = auto_register @requires = requires @body = body end |
Instance Method Details
#create(force: false) ⇒ 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.
35 36 37 |
# File 'lib/hanami/cli/generators/app/ruby_file.rb', line 35 def create(force: false) fs.create(path, file_contents, force:) end |
#fully_qualified_name ⇒ 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.
45 46 47 48 49 |
# File 'lib/hanami/cli/generators/app/ruby_file.rb', line 45 def fully_qualified_name inflector.camelize( [namespace, extra_namespace, *key_segments].compact.join("/") ) end |
#path ⇒ 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.
52 53 54 |
# File 'lib/hanami/cli/generators/app/ruby_file.rb', line 52 def path fs.join(directory, "#{key_segments.last}.rb") end |
#write ⇒ 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.
40 41 42 |
# File 'lib/hanami/cli/generators/app/ruby_file.rb', line 40 def write fs.write(path, file_contents) end |