Class: Foobara::CommandConnectors::Http::Commands::Help

Inherits:
Foobara::Command show all
Defined in:
foobara-http-command-connector-0.0.23/src/http/commands/help.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/root.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/type.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/error.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/model.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/domain.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/entity.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/command.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/result_serializer.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/processor.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/organization.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/request_failed.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/processor_class.rb

Defined Under Namespace

Classes: Presenter, ResultSerializer

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary collapse

Attributes included from Foobara::CommandPatternImplementation::Concerns::Subcommands

#is_subcommand

Attributes included from Foobara::CommandPatternImplementation::Concerns::Runtime

#exception, #outcome

Attributes included from Foobara::CommandPatternImplementation::Concerns::Errors

#error_collection

Attributes included from Foobara::CommandPatternImplementation::Concerns::Inputs

#inputs, #raw_inputs

Instance Method Summary collapse

Methods inherited from Foobara::Command

install!, reset_all

Methods included from Foobara::Concern

foobara_class_methods_module_for, foobara_concern?, included

Methods included from Foobara::CommandPatternImplementation::Concerns::Reflection

#initialize

Methods included from Foobara::CommandPatternImplementation::Concerns::DomainMappers

#domain_map, #domain_map!, #run_mapped_subcommand!

Methods included from Foobara::CommandPatternImplementation::Concerns::Subcommands

#run_subcommand!, #subcommand?

Methods included from Foobara::CommandPatternImplementation::Concerns::Entities

#load_entities, #load_records

Methods included from Foobara::CommandPatternImplementation::Concerns::Transactions

#auto_detect_current_transactions, #commit_transaction, #open_transaction, #opened_transactions, #relevant_entity_classes, #rollback_transaction, #transactions

Methods included from Foobara::CommandPatternImplementation::Concerns::StateMachine

#state_machine

Methods included from Foobara::CommandPatternImplementation::Concerns::Runtime

#halt!, #run, #run!, #run_execute, #succeed, #success?, #validate, #validate_records

Methods included from Foobara::CommandPatternImplementation::Concerns::Errors

#initialize

Methods included from Foobara::CommandPatternImplementation::Concerns::Inputs

#cast_and_validate_inputs, #initialize, #method_missing, #respond_to_missing?, #respond_to_missing_for_inputs?

Methods included from TruncatedInspect

#inspect, truncating

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Foobara::CommandPatternImplementation::Concerns::Inputs

Instance Attribute Details

#manifest_to_help_withObject

Returns the value of attribute manifest_to_help_with.



19
20
21
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help.rb', line 19

def manifest_to_help_with
  @manifest_to_help_with
end

#object_to_help_withObject

Returns the value of attribute object_to_help_with.



19
20
21
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help.rb', line 19

def object_to_help_with
  @object_to_help_with
end

#raw_manifestObject

Returns the value of attribute raw_manifest.



19
20
21
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help.rb', line 19

def raw_manifest
  @raw_manifest
end

#root_manifestObject

Returns the value of attribute root_manifest.



19
20
21
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help.rb', line 19

def root_manifest
  @root_manifest
end

Instance Method Details

#command_connectorObject



63
64
65
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help.rb', line 63

def command_connector
  request.command_connector
end

#determine_object_to_help_with(mode: Namespace::LookupMode::ABSOLUTE) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help.rb', line 26

def determine_object_to_help_with(mode: Namespace::LookupMode::ABSOLUTE)
  arg = request.argument

  if arg
    result = command_connector.command_registry.foobara_lookup(arg, mode:)

    if result
      self.object_to_help_with = result
    else
      # TODO: we should look up from the command connector's namespace instead, right?
      result = GlobalOrganization.foobara_lookup(arg, mode:)

      if result && root_manifest.contains?(result.foobara_manifest_reference,
                                           result.scoped_category)
        self.object_to_help_with = result
      elsif mode == Namespace::LookupMode::ABSOLUTE
        determine_object_to_help_with(mode: Namespace::LookupMode::GENERAL)
      elsif mode == Namespace::LookupMode::GENERAL
        determine_object_to_help_with(mode: Namespace::LookupMode::RELAXED)
      else
        # TODO: add an input error instead for missing record to trigger 404
        add_runtime_error(CommandConnector::NotFoundError.for(arg))
      end
    end
  else
    self.object_to_help_with = root_manifest
  end
end

#executeObject



11
12
13
14
15
16
17
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help.rb', line 11

def execute
  load_manifest
  determine_object_to_help_with
  set_manifest_to_help_with

  manifest_to_help_with
end

#load_manifestObject



21
22
23
24
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help.rb', line 21

def load_manifest
  self.raw_manifest = command_connector.foobara_manifest
  self.root_manifest = Manifest::RootManifest.new(raw_manifest)
end

#set_manifest_to_help_withObject



55
56
57
58
59
60
61
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help.rb', line 55

def set_manifest_to_help_with
  self.manifest_to_help_with = if object_to_help_with.is_a?(Manifest::BaseManifest)
                                 object_to_help_with
                               else
                                 root_manifest.lookup(object_to_help_with.foobara_manifest_reference)
                               end
end