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, #humanized_slice_name, #javascript_erb_tag, #stylesheet_erb_tag, #underscored_slice_name
Methods inherited from Context
#bundled_assets?, #bundled_views?, #camelized_app_name, #ctx, #generate_assets?, #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.
17 18 19 20 21 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 17 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.
33 34 35 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 33 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.
25 26 27 28 29 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 25 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.
53 54 55 56 57 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 53 def module_controller_declaration controller.each_with_index.map do |token, i| "#{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.
61 62 63 64 65 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 61 def module_controller_end controller.each_with_index.map do |_, i| "#{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.
69 70 71 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 69 def module_controller_offset "#{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.
75 76 77 78 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 75 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.
47 48 49 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 47 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.
39 40 41 42 43 |
# File 'lib/hanami/cli/generators/app/action_context.rb', line 39 def underscored_controller_name controller.map do |token| inflector.underscore(token) end end |