Class: Hanami::CLI::Generators::App::ViewContext Private
- Inherits:
-
SliceContext
- Object
- Context
- SliceContext
- Hanami::CLI::Generators::App::ViewContext
- Defined in:
- lib/hanami/cli/generators/app/view_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 Attribute Summary collapse
- #key ⇒ Object readonly private
Instance Method Summary collapse
- #camelized_name ⇒ Object private
- #camelized_namespace ⇒ Object private
-
#initialize(inflector, app, slice, key) ⇒ ViewContext
constructor
private
A new instance of ViewContext.
- #module_namespace_declaration ⇒ Object private
- #module_namespace_end ⇒ Object private
- #module_namespace_offset ⇒ Object private
- #name ⇒ Object private
- #namespaces ⇒ Object private
- #underscored_name ⇒ Object private
- #underscored_namespace ⇒ 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, key) ⇒ ViewContext
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 ViewContext.
22 23 24 25 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 22 def initialize(inflector, app, slice, key) @key = key super(inflector, app, slice, nil) end |
Instance Attribute Details
#key ⇒ Object (readonly)
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.
18 19 20 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 18 def key @key end |
Instance Method Details
#camelized_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/view_context.rb', line 47 def camelized_name inflector.camelize(name) end |
#camelized_namespace ⇒ 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.
41 42 43 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 41 def camelized_namespace namespaces.map { inflector.camelize(_1) }.join(NAMESPACE_SEPARATOR) end |
#module_namespace_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.
65 66 67 68 69 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 65 def module_namespace_declaration namespaces.each_with_index.map { |token, i| "#{NESTED_OFFSET}#{INDENTATION * i}module #{inflector.camelize(token)}" }.join($/) end |
#module_namespace_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.
73 74 75 76 77 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 73 def module_namespace_end namespaces.each_with_index.map { |_, i| "#{NESTED_OFFSET}#{INDENTATION * i}end" }.reverse.join($/) end |
#module_namespace_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.
81 82 83 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 81 def module_namespace_offset "#{NESTED_OFFSET}#{INDENTATION * namespaces.count}" end |
#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.
35 36 37 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 35 def name @name ||= key.split(KEY_SEPARATOR)[-1] end |
#namespaces ⇒ 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.
29 30 31 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 29 def namespaces @namespaces ||= key.split(KEY_SEPARATOR)[..-2] end |
#underscored_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.
59 60 61 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 59 def underscored_name inflector.underscore(name) end |
#underscored_namespace ⇒ 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 |
# File 'lib/hanami/cli/generators/app/view_context.rb', line 53 def underscored_namespace namespaces.map { inflector.underscore(_1) } end |