Class: Slk::Services::WhoTargetResolver
- Inherits:
-
Object
- Object
- Slk::Services::WhoTargetResolver
- Defined in:
- lib/slk/services/who_target_resolver.rb
Overview
Resolves the positional target for ‘slk who` into one or more user_ids.
Instance Method Summary collapse
-
#initialize(workspace:, cache_store:, api_client:, output:, options:) ⇒ WhoTargetResolver
constructor
A new instance of WhoTargetResolver.
- #resolve(target) ⇒ Object
Constructor Details
#initialize(workspace:, cache_store:, api_client:, output:, options:) ⇒ WhoTargetResolver
Returns a new instance of WhoTargetResolver.
7 8 9 10 11 12 13 |
# File 'lib/slk/services/who_target_resolver.rb', line 7 def initialize(workspace:, cache_store:, api_client:, output:, options:) @workspace = workspace @cache_store = cache_store @api_client = api_client @output = output @options = end |
Instance Method Details
#resolve(target) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/slk/services/who_target_resolver.rb', line 15 def resolve(target) return [self_user_id] if target.nil? || target == 'me' return [target] if target.match?(/\A[UW][A-Z0-9]+\z/) ids = resolve_by_name(target.delete_prefix('@')) ids || (raise ApiError, "Could not resolve user: #{target}") end |