Class: ROM::Commands::Lazy Private
- Inherits:
-
Object
- Object
- ROM::Commands::Lazy
- Defined in:
- lib/rom/commands/lazy.rb,
lib/rom/commands/lazy/create.rb,
lib/rom/commands/lazy/delete.rb,
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.
34 35 36 37 38 |
# File 'lib/rom/commands/lazy.rb', line 34 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.
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rom/commands/lazy.rb', line 84 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.
13 14 15 |
# File 'lib/rom/commands/lazy.rb', line 13 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.
20 21 22 |
# File 'lib/rom/commands/lazy.rb', line 20 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.
18 19 20 |
# File 'lib/rom/commands/lazy.rb', line 18 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.
23 24 25 26 27 28 29 30 31 |
# File 'lib/rom/commands/lazy.rb', line 23 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
56 57 58 |
# File 'lib/rom/commands/lazy.rb', line 56 def >>(other) Composite.new(self, other) end |
#call(*args) ⇒ Array, Hash
Evaluate command’s input using the input proc and pass to command
45 46 47 |
# File 'lib/rom/commands/lazy.rb', line 45 def call(*args) raise NotImplementedError end |
#combine(*others) ⇒ Graph
Combine with other lazy commands
67 68 69 |
# File 'lib/rom/commands/lazy.rb', line 67 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.
72 73 74 |
# File 'lib/rom/commands/lazy.rb', line 72 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.
77 78 79 |
# File 'lib/rom/commands/lazy.rb', line 77 def respond_to_missing?(name, include_private = false) super || command.respond_to?(name) end |