Class: Jets::Commands::Call::BaseGuesser

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/commands/call/base_guesser.rb

Direct Known Subclasses

AnonymousGuesser, AutoloadGuesser

Instance Method Summary collapse

Constructor Details

#initialize(provided_function_name) ⇒ BaseGuesser

provided_function_name:

admin/related_pages_controller-list_all
admin-related-pages-controller-list-all


11
12
13
# File 'lib/jets/commands/call/base_guesser.rb', line 11

def initialize(provided_function_name)
  @provided_function_name = provided_function_name
end

Instance Method Details

#class_nameObject



15
16
17
18
19
20
21
# File 'lib/jets/commands/call/base_guesser.rb', line 15

def class_name
  return @class_name if @detection_ran

  @class_name = detect_class_name
  @detection_ran = true
  @class_name
end

#function_nameObject



23
24
25
26
27
28
29
30
31
# File 'lib/jets/commands/call/base_guesser.rb', line 23

def function_name
  # Strip the project namespace if the user has accidentally added it
  # Since we're going to automatically add it no matter what at the end
  # and dont want the namespace to be included twice
  @provided_function_name = @provided_function_name.sub("#{Jets.config.project_namespace}-", "")

  code_path = class_name.underscore.gsub('/','-')
  function_name = [Jets.config.project_namespace, code_path, method_name].join('-')
end