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 ⇒ Object private
- #fully_qualified_name ⇒ Object private
-
#initialize(fs:, inflector:, key:, namespace:, base_path:, extra_namespace: nil, auto_register: nil, 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, 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 |
# 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, 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 @body = body end |
Instance Method Details
#create ⇒ 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.
33 34 35 |
# File 'lib/hanami/cli/generators/app/ruby_file.rb', line 33 def create fs.create(path, file_contents) 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.
43 44 45 46 47 |
# File 'lib/hanami/cli/generators/app/ruby_file.rb', line 43 def fully_qualified_name inflector.camelize( [namespace, extra_namespace, *key_segments].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.
50 51 52 |
# File 'lib/hanami/cli/generators/app/ruby_file.rb', line 50 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.
38 39 40 |
# File 'lib/hanami/cli/generators/app/ruby_file.rb', line 38 def write fs.write(path, file_contents) end |