Class: Hanami::CLI::Generators::App::ActionContext Private
- Inherits:
-
SliceContext
- Object
- Context
- SliceContext
- Hanami::CLI::Generators::App::ActionContext
- Defined in:
- lib/hanami/cli/generators/app/action_context.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
- #camelized_action_name ⇒ Object private
- #camelized_controller_name ⇒ Object private
-
#initialize(inflector, app, slice, controller, action) ⇒ ActionContext
constructor
private
A new instance of ActionContext.
- #module_controller_declaration ⇒ Object private
- #module_controller_end ⇒ Object private
- #module_controller_offset ⇒ Object private
- #template_path ⇒ Object private
- #underscored_action_name ⇒ Object private
- #underscored_controller_name ⇒ Object private
Methods inherited from SliceContext
#camelized_slice_name, #generate_db?, #generate_route?, #humanized_slice_name, #javascript_erb_tag, #stylesheet_erb_tag, #underscored_slice_name
Methods inherited from Context
#bundled_assets?, #bundled_dry_monads?, #bundled_views?, #camelized_app_name, #ctx, #database_url, #generate_assets?, #generate_db?, #generate_mysql?, #generate_postgres?, #generate_sqlite?, #hanami_assets_npm_package, #hanami_gem, #hanami_gem_version, #hanami_head?, #humanized_app_name, #ruby_omit_hash_values?, #underscored_app_name
Constructor Details
#initialize(inflector, app, slice, controller, action) ⇒ ActionContext
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 ActionContext.
18 19 20 21 22 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 18 def initialize(inflector, app, slice, controller, action) @controller = controller @action = action super(inflector, app, slice, nil) end |
Instance Method Details
#camelized_action_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.
34 35 36 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 34 def camelized_action_name inflector.camelize(action) end |
#camelized_controller_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.
26 27 28 29 30 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 26 def camelized_controller_name controller.map do |token| inflector.camelize(token) end.join(NAMESPACE_SEPARATOR) end |
#module_controller_declaration ⇒ 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.
54 55 56 57 58 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 54 def module_controller_declaration controller.each_with_index.map do |token, i| "#{NESTED_OFFSET}#{INDENTATION * i}module #{inflector.camelize(token)}" end.join($/) end |
#module_controller_end ⇒ 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.
62 63 64 65 66 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 62 def module_controller_end controller.each_with_index.map do |_, i| "#{NESTED_OFFSET}#{INDENTATION * i}end" end.reverse.join($/) end |
#module_controller_offset ⇒ 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.
70 71 72 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 70 def module_controller_offset "#{NESTED_OFFSET}#{INDENTATION * controller.count}" end |
#template_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.
76 77 78 79 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 76 def template_path Dry::Files::Path["slices", underscored_slice_name, "templates", *underscored_controller_name, "#{underscored_action_name}.html.erb"] end |
#underscored_action_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.
48 49 50 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 48 def underscored_action_name inflector.underscore(action) end |
#underscored_controller_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.
40 41 42 43 44 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 40 def underscored_controller_name controller.map do |token| inflector.underscore(token) end end |