Class: Textus::Action::Where

Inherits:
Base
  • Object
show all
Extended by:
Contract::DSL
Defined in:
lib/textus/action/where.rb

Constant Summary collapse

BURN =
:sync

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Contract::DSL

arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view

Methods inherited from Base

#args, inherited

Constructor Details

#initialize(key:) ⇒ Where

Returns a new instance of Where.



16
17
18
19
# File 'lib/textus/action/where.rb', line 16

def initialize(key:)
  super()
  @key = key
end

Class Method Details

.new(*args, **kwargs) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/textus/action/where.rb', line 29

def self.new(*args, **kwargs)
  return super(**kwargs) unless args.any?

  positional = instance_method(:initialize).parameters.slice(:keyreq, :key).map(&:last)
  mapped = positional.zip(args).to_h
  super(**mapped.merge(kwargs))
end

Instance Method Details

#call(container:, call: nil) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



21
22
23
24
25
26
27
# File 'lib/textus/action/where.rb', line 21

def call(container:, call: nil) # rubocop:disable Lint/UnusedMethodArgument
  manifest = container.manifest
  res = manifest.resolver.resolve(@key)
  mentry = res.entry
  path = res.path
  { "protocol" => PROTOCOL, "key" => @key, "lane" => mentry.lane, "owner" => mentry.owner, "path" => path }
end