Class: VerifiedDouble::SimpleDouble
- Inherits:
-
Object
- Object
- VerifiedDouble::SimpleDouble
- Defined in:
- lib/verified_double/simple_double.rb
Instance Attribute Summary collapse
-
#internal ⇒ Object
readonly
Returns the value of attribute internal.
Instance Method Summary collapse
- #any_instance_double? ⇒ Boolean
- #build_recorded_method_signature(method) ⇒ Object
- #class_double? ⇒ Boolean
- #class_name ⇒ Object
-
#initialize(internal) ⇒ SimpleDouble
constructor
A new instance of SimpleDouble.
- #instance_double? ⇒ Boolean
- #method_operator ⇒ Object
Constructor Details
#initialize(internal) ⇒ SimpleDouble
Returns a new instance of SimpleDouble.
5 6 7 |
# File 'lib/verified_double/simple_double.rb', line 5 def initialize(internal) @internal = internal end |
Instance Attribute Details
#internal ⇒ Object (readonly)
Returns the value of attribute internal.
3 4 5 |
# File 'lib/verified_double/simple_double.rb', line 3 def internal @internal end |
Instance Method Details
#any_instance_double? ⇒ Boolean
29 30 31 |
# File 'lib/verified_double/simple_double.rb', line 29 def any_instance_double? !! internal.instance_variable_get('@target') end |
#build_recorded_method_signature(method) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/verified_double/simple_double.rb', line 9 def build_recorded_method_signature(method) RecordedMethodSignature.new( class_name: class_name, method_operator: method_operator, method: method.to_s) end |
#class_double? ⇒ Boolean
33 34 35 |
# File 'lib/verified_double/simple_double.rb', line 33 def class_double? internal.respond_to?(:verified_class_double?) end |
#class_name ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/verified_double/simple_double.rb', line 17 def class_name if class_double? internal.name elsif instance_double? internal.instance_variable_get('@name').to_s elsif any_instance_double? internal.instance_variable_get('@target').to_s else internal.class.name end end |
#instance_double? ⇒ Boolean
37 38 39 |
# File 'lib/verified_double/simple_double.rb', line 37 def instance_double? !! internal.instance_variable_get('@name') end |
#method_operator ⇒ Object
41 42 43 |
# File 'lib/verified_double/simple_double.rb', line 41 def method_operator class_double? ? '.' : '#' end |