Class: Aspera::Cli::Command::Mount
- Inherits:
-
Struct
- Object
- Struct
- Aspera::Cli::Command::Mount
- Defined in:
- lib/aspera/cli/command/mount.rb
Overview
Declares that a command node exposes a sub-tree of another plugin class. The mounted children appear in the host registry (dispatch, --help, completion) as if they were declared by the host; host children with the same id take precedence.
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Arguments read by the host after the mounted command, before its own arguments; resolved values are passed to
instance(e.g.packages ls <package_id> <path>). -
#at ⇒ Object
readonly
Path in the target registry whose children are mounted ([] = root).
-
#except ⇒ Object
readonly
Exclude these ids from mounted children.
-
#only ⇒ Object
readonly
Restrict mounted children to these ids.
Instance Method Summary collapse
-
#accepts?(id) ⇒ Boolean
True if this child is exposed by the mount.
-
#initialize(**kwargs) ⇒ Mount
constructor
A new instance of Mount.
-
#instance(value) ⇒ Object
Host instance method called with **ctx, returning the target plugin instance, or [instance, ctx] where ctx seeds the target dispatch (it replaces what the setups of
atand its ancestors would provide). -
#plugin(value) ⇒ Object
Target plugin class (subclass of Plugins::Base).
-
#registry ⇒ Command::Registry
Registry of the target plugin class.
Constructor Details
#initialize(**kwargs) ⇒ Mount
Returns a new instance of Mount.
34 35 36 37 38 |
# File 'lib/aspera/cli/command/mount.rb', line 34 def initialize(**kwargs) kwargs[:at] = Array(kwargs[:at]).freeze kwargs[:arguments] = Array(kwargs[:arguments]).map { |a| a.is_a?(Hash) ? Argument.new(**a) : a }.freeze super end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Arguments read by the host after the mounted command, before its own
arguments; resolved values are passed to instance
(e.g. packages ls <package_id> <path>)
25 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 |
# File 'lib/aspera/cli/command/mount.rb', line 25 Mount = Struct.new( :plugin, :at, :instance, :only, :except, :arguments, keyword_init: true ) do def initialize(**kwargs) kwargs[:at] = Array(kwargs[:at]).freeze kwargs[:arguments] = Array(kwargs[:arguments]).map { |a| a.is_a?(Hash) ? Argument.new(**a) : a }.freeze super end # @return [Command::Registry] registry of the target plugin class def registry plugin.command_registry end # @param id [Symbol] id of a child of `at` in the target registry # @return [Boolean] true if this child is exposed by the mount def accepts?(id) (only.nil? || only.include?(id)) && !except&.include?(id) end end |
#at ⇒ Object (readonly)
Path in the target registry whose children are mounted ([] = root)
25 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 |
# File 'lib/aspera/cli/command/mount.rb', line 25 Mount = Struct.new( :plugin, :at, :instance, :only, :except, :arguments, keyword_init: true ) do def initialize(**kwargs) kwargs[:at] = Array(kwargs[:at]).freeze kwargs[:arguments] = Array(kwargs[:arguments]).map { |a| a.is_a?(Hash) ? Argument.new(**a) : a }.freeze super end # @return [Command::Registry] registry of the target plugin class def registry plugin.command_registry end # @param id [Symbol] id of a child of `at` in the target registry # @return [Boolean] true if this child is exposed by the mount def accepts?(id) (only.nil? || only.include?(id)) && !except&.include?(id) end end |
#except ⇒ Object (readonly)
Exclude these ids from mounted children
25 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 |
# File 'lib/aspera/cli/command/mount.rb', line 25 Mount = Struct.new( :plugin, :at, :instance, :only, :except, :arguments, keyword_init: true ) do def initialize(**kwargs) kwargs[:at] = Array(kwargs[:at]).freeze kwargs[:arguments] = Array(kwargs[:arguments]).map { |a| a.is_a?(Hash) ? Argument.new(**a) : a }.freeze super end # @return [Command::Registry] registry of the target plugin class def registry plugin.command_registry end # @param id [Symbol] id of a child of `at` in the target registry # @return [Boolean] true if this child is exposed by the mount def accepts?(id) (only.nil? || only.include?(id)) && !except&.include?(id) end end |
#only ⇒ Object (readonly)
Restrict mounted children to these ids
25 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 |
# File 'lib/aspera/cli/command/mount.rb', line 25 Mount = Struct.new( :plugin, :at, :instance, :only, :except, :arguments, keyword_init: true ) do def initialize(**kwargs) kwargs[:at] = Array(kwargs[:at]).freeze kwargs[:arguments] = Array(kwargs[:arguments]).map { |a| a.is_a?(Hash) ? Argument.new(**a) : a }.freeze super end # @return [Command::Registry] registry of the target plugin class def registry plugin.command_registry end # @param id [Symbol] id of a child of `at` in the target registry # @return [Boolean] true if this child is exposed by the mount def accepts?(id) (only.nil? || only.include?(id)) && !except&.include?(id) end end |
Instance Method Details
#accepts?(id) ⇒ Boolean
Returns true if this child is exposed by the mount.
47 48 49 |
# File 'lib/aspera/cli/command/mount.rb', line 47 def accepts?(id) (only.nil? || only.include?(id)) && !except&.include?(id) end |
#instance=(value) ⇒ Object
Host instance method called with **ctx, returning the target plugin
instance, or [instance, ctx] where ctx seeds the target dispatch
(it replaces what the setups of at and its ancestors would provide)
25 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 |
# File 'lib/aspera/cli/command/mount.rb', line 25 Mount = Struct.new( :plugin, :at, :instance, :only, :except, :arguments, keyword_init: true ) do def initialize(**kwargs) kwargs[:at] = Array(kwargs[:at]).freeze kwargs[:arguments] = Array(kwargs[:arguments]).map { |a| a.is_a?(Hash) ? Argument.new(**a) : a }.freeze super end # @return [Command::Registry] registry of the target plugin class def registry plugin.command_registry end # @param id [Symbol] id of a child of `at` in the target registry # @return [Boolean] true if this child is exposed by the mount def accepts?(id) (only.nil? || only.include?(id)) && !except&.include?(id) end end |
#plugin=(value) ⇒ Object
Target plugin class (subclass of Plugins::Base)
25 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 |
# File 'lib/aspera/cli/command/mount.rb', line 25 Mount = Struct.new( :plugin, :at, :instance, :only, :except, :arguments, keyword_init: true ) do def initialize(**kwargs) kwargs[:at] = Array(kwargs[:at]).freeze kwargs[:arguments] = Array(kwargs[:arguments]).map { |a| a.is_a?(Hash) ? Argument.new(**a) : a }.freeze super end # @return [Command::Registry] registry of the target plugin class def registry plugin.command_registry end # @param id [Symbol] id of a child of `at` in the target registry # @return [Boolean] true if this child is exposed by the mount def accepts?(id) (only.nil? || only.include?(id)) && !except&.include?(id) end end |
#registry ⇒ Command::Registry
Returns registry of the target plugin class.
41 42 43 |
# File 'lib/aspera/cli/command/mount.rb', line 41 def registry plugin.command_registry end |