Class: Naught::NullClassBuilder::Commands::Mimic Private
- Inherits:
-
Naught::NullClassBuilder::Command
- Object
- Naught::NullClassBuilder::Command
- Naught::NullClassBuilder::Commands::Mimic
- Defined in:
- lib/naught/null_class_builder/commands/mimic.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.
Build a null class that mimics an existing class or instance
Direct Known Subclasses
Instance Attribute Summary collapse
-
#class_to_mimic ⇒ Class
readonly
private
The class being mimicked by the null object.
-
#example_instance ⇒ Object?
readonly
private
The example instance for dynamic method discovery.
-
#include_dynamic ⇒ Boolean
readonly
private
Whether to include dynamically-defined methods.
-
#include_super ⇒ Boolean
readonly
private
Whether to include superclass methods when mimicking.
-
#singleton_class ⇒ Class
readonly
private
The singleton class being mimicked (for instance-based mimicking).
Attributes inherited from Naught::NullClassBuilder::Command
Instance Method Summary collapse
-
#call ⇒ void
private
Install stubbed methods from the target class or instance.
-
#initialize(builder, class_to_mimic_or_options, options = {}) ⇒ Mimic
constructor
private
Create a mimic command for a class or instance.
Constructor Details
#initialize(builder, class_to_mimic_or_options, options = {}) ⇒ Mimic
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.
Create a mimic command for a class or instance
47 48 49 50 51 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 47 def initialize(builder, , = {}) super(builder) parse_arguments(, ) configure_builder end |
Instance Attribute Details
#class_to_mimic ⇒ Class (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.
The class being mimicked by the null object
23 24 25 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 23 def class_to_mimic @class_to_mimic end |
#example_instance ⇒ 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.
The example instance for dynamic method discovery
35 36 37 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 35 def example_instance @example_instance end |
#include_dynamic ⇒ Boolean (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.
Whether to include dynamically-defined methods
39 40 41 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 39 def include_dynamic @include_dynamic end |
#include_super ⇒ Boolean (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.
Whether to include superclass methods when mimicking
27 28 29 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 27 def include_super @include_super end |
#singleton_class ⇒ Class (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.
The singleton class being mimicked (for instance-based mimicking)
31 32 33 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 31 def singleton_class @singleton_class end |
Instance Method Details
#call ⇒ void
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.
This method returns an undefined value.
Install stubbed methods from the target class or instance
57 58 59 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 57 def call defer { |subject| methods_to_stub.each { |name| builder.stub_method(subject, name) } } end |