Class: Naught::NullClassBuilder::Commands::Mimic
- Inherits:
-
Naught::NullClassBuilder::Command
- Object
- Naught::NullClassBuilder::Command
- Naught::NullClassBuilder::Commands::Mimic
- Defined in:
- lib/naught/null_class_builder/commands/mimic.rb
Direct Known Subclasses
Constant Summary collapse
- NULL_SINGLETON_CLASS =
(class << Object.new; self; end)
Instance Attribute Summary collapse
-
#class_to_mimic ⇒ Object
readonly
Returns the value of attribute class_to_mimic.
-
#include_super ⇒ Object
readonly
Returns the value of attribute include_super.
-
#singleton_class ⇒ Object
readonly
Returns the value of attribute singleton_class.
Attributes inherited from Naught::NullClassBuilder::Command
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(builder, class_to_mimic_or_options, options = {}) ⇒ Mimic
constructor
A new instance of Mimic.
Methods inherited from Naught::NullClassBuilder::Command
Constructor Details
#initialize(builder, class_to_mimic_or_options, options = {}) ⇒ Mimic
Returns a new instance of Mimic.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 12 def initialize(builder, , = {}) super(builder) if .is_a?(Hash) = .merge() instance = .fetch(:example) @singleton_class = (class << instance; self; end) @class_to_mimic = instance.class else @singleton_class = NULL_SINGLETON_CLASS @class_to_mimic = end @include_super = .fetch(:include_super) { true } builder.base_class = root_class_of(@class_to_mimic) class_to_mimic = @class_to_mimic builder.inspect_proc = lambda { "<null:#{class_to_mimic}>" } builder.interface_defined = true end |
Instance Attribute Details
#class_to_mimic ⇒ Object (readonly)
Returns the value of attribute class_to_mimic.
10 11 12 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 10 def class_to_mimic @class_to_mimic end |
#include_super ⇒ Object (readonly)
Returns the value of attribute include_super.
10 11 12 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 10 def include_super @include_super end |
#singleton_class ⇒ Object (readonly)
Returns the value of attribute singleton_class.
10 11 12 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 10 def singleton_class @singleton_class end |
Instance Method Details
#call ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/naught/null_class_builder/commands/mimic.rb', line 32 def call defer do |subject| methods_to_stub.each do |method_name| builder.stub_method(subject, method_name) end end end |