Class: Loom::Shell::Api
- Inherits:
-
Object
- Object
- Loom::Shell::Api
- Defined in:
- lib/loom/shell/api.rb
Overview
A facade for the shell API exposed to Loom files. This is the loom
object passed to patterns.
Direct Known Subclasses
Instance Method Summary collapse
- #dry_run? ⇒ Boolean
-
#initialize(shell) ⇒ Api
constructor
A new instance of Api.
- #local ⇒ Object
-
#method_missing(name, *args, **kwargs, &block) ⇒ Object
This is the entry point for ‘loom.foo` calls from .loom files.
Constructor Details
#initialize(shell) ⇒ Api
Returns a new instance of Api.
8 9 10 11 12 |
# File 'lib/loom/shell/api.rb', line 8 def initialize(shell) @shell = shell @mod_loader = shell.mod_loader @dry_run = shell.dry_run end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kwargs, &block) ⇒ Object
This is the entry point for ‘loom.foo` calls from .loom files.
23 24 25 26 27 28 29 30 31 |
# File 'lib/loom/shell/api.rb', line 23 def method_missing(name, *args, **kwargs, &block) Loom.log.debug3(self) { "shell api => #{name} #{args} #{kwargs} #{block}" } # TODO: The relationship between shell and mod_loader seems leaky here, a # Shell::Api should have a shell and not care about the mod_loader, # currently it seems to violate Demeter. The shell should dispatch to the # mod_loader only as an implementation detail. Otherwise this is harder to # test. @mod_loader.send name, @shell, *args, **kwargs, &block end |
Instance Method Details
#dry_run? ⇒ Boolean
14 15 16 |
# File 'lib/loom/shell/api.rb', line 14 def dry_run? @dry_run end |
#local ⇒ Object
18 19 20 |
# File 'lib/loom/shell/api.rb', line 18 def local @shell.local.shell_api end |