Class: ROM::Commands::Lazy Private
- Inherits:
-
Object
- Object
- ROM::Commands::Lazy
- Defined in:
- core/lib/rom/commands/lazy.rb,
core/lib/rom/commands/lazy/create.rb,
core/lib/rom/commands/lazy/delete.rb,
core/lib/rom/commands/lazy/update.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Lazy command wraps another command and evaluates its input when called
Defined Under Namespace
Classes: Create, Delete, Update
Instance Attribute Summary collapse
- #command ⇒ Object (also: #unwrap) readonly private
- #command_proc ⇒ Object readonly private
- #evaluator ⇒ Object readonly private
Class Method Summary collapse
- .[](command) ⇒ Object private
Instance Method Summary collapse
-
#>>(other) ⇒ Composite
Compose a lazy command with another one.
-
#call(*_args) ⇒ Array, Hash
Evaluate command's input using the input proc and pass to command.
-
#combine(*others) ⇒ Graph
Combine with other lazy commands.
-
#initialize(command, evaluator, command_proc = nil) ⇒ Lazy
constructor
private
A new instance of Lazy.
- #lazy? ⇒ Boolean private
- #respond_to_missing?(name, include_private = false) ⇒ Boolean private
Constructor Details
#initialize(command, evaluator, command_proc = nil) ⇒ Lazy
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Lazy.
36 37 38 39 40 |
# File 'core/lib/rom/commands/lazy.rb', line 36 def initialize(command, evaluator, command_proc = nil) @command = command @evaluator = evaluator @command_proc = command_proc || proc { |*| command } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'core/lib/rom/commands/lazy.rb', line 86 def method_missing(name, *args, &block) if command.respond_to?(name) response = command.public_send(name, *args, &block) if response.instance_of?(command.class) self.class.new(response, evaluator, command_proc) else response end else super end end |
Instance Attribute Details
#command ⇒ Object (readonly) Also known as: unwrap
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'core/lib/rom/commands/lazy.rb', line 15 def command @command end |
#command_proc ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'core/lib/rom/commands/lazy.rb', line 22 def command_proc @command_proc end |
#evaluator ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'core/lib/rom/commands/lazy.rb', line 20 def evaluator @evaluator end |
Class Method Details
.[](command) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 33 |
# File 'core/lib/rom/commands/lazy.rb', line 25 def self.[](command) case command when Commands::Create then Lazy::Create when Commands::Update then Lazy::Update when Commands::Delete then Lazy::Delete else self end end |
Instance Method Details
#>>(other) ⇒ Composite
Compose a lazy command with another one
58 59 60 |
# File 'core/lib/rom/commands/lazy.rb', line 58 def >>(other) Composite.new(self, other) end |
#call(*_args) ⇒ Array, Hash
Evaluate command's input using the input proc and pass to command
47 48 49 |
# File 'core/lib/rom/commands/lazy.rb', line 47 def call(*_args) raise NotImplementedError end |
#combine(*others) ⇒ Graph
Combine with other lazy commands
69 70 71 |
# File 'core/lib/rom/commands/lazy.rb', line 69 def combine(*others) Graph.new(self, others) end |
#lazy? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 |
# File 'core/lib/rom/commands/lazy.rb', line 74 def lazy? true end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 |
# File 'core/lib/rom/commands/lazy.rb', line 79 def respond_to_missing?(name, include_private = false) super || command.respond_to?(name) end |