Class: Hanami::RSpec::Generators::Part Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/rspec/generators/part.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.

Since:

  • 2.1.0

Instance Method Summary collapse

Constructor Details

#initialize(fs:, inflector:) ⇒ Part

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 Part.

Since:

  • 2.1.0



13
14
15
16
# File 'lib/hanami/rspec/generators/part.rb', line 13

def initialize(fs:, inflector:)
  @fs = fs
  @inflector = inflector
end

Instance Method Details

#call(app, slice, 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.

Since:

  • 2.1.0



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/hanami/rspec/generators/part.rb', line 20

def call(app, slice, name)
  context = Struct.new(
    :camelized_app_name,
    :camelized_slice_name,
    :camelized_name,
    :underscored_name
  ).new(
    inflector.camelize(app),
    slice ? inflector.camelize(slice) : nil,
    inflector.camelize(name),
    inflector.underscore(name)
  )

  if slice
    generate_for_slice(slice, context)
  else
    generate_for_app(context)
  end
end