Class: VerifiedDouble::MethodSignatureValue
- Inherits:
-
Object
- Object
- VerifiedDouble::MethodSignatureValue
- Defined in:
- lib/verified_double/method_signature_value.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #accepts?(other) ⇒ Boolean
- #as_instance ⇒ Object
-
#initialize(value) ⇒ MethodSignatureValue
constructor
A new instance of MethodSignatureValue.
- #modified_class ⇒ Object
- #recommended_value ⇒ Object
Constructor Details
#initialize(value) ⇒ MethodSignatureValue
Returns a new instance of MethodSignatureValue.
5 6 7 |
# File 'lib/verified_double/method_signature_value.rb', line 5 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/verified_double/method_signature_value.rb', line 3 def value @value end |
Instance Method Details
#accepts?(other) ⇒ Boolean
9 10 11 12 13 14 15 |
# File 'lib/verified_double/method_signature_value.rb', line 9 def accepts?(other) if self.value.is_a?(Class) || ! other.value.is_a?(Class) self.value == other.value else self.modified_class.ancestors.include?(other.value) end end |
#as_instance ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/verified_double/method_signature_value.rb', line 17 def as_instance if self.value.is_a?(Class) begin value.new rescue NoMethodError Object.new end else self.value end end |
#modified_class ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/verified_double/method_signature_value.rb', line 29 def modified_class if value.is_a?(RSpec::Mocks::Mock) value.instance_variable_get('@name').constantize elsif value.is_a?(VerifiedDouble::RecordingDouble) value.class_name.constantize elsif value == true or value == false VerifiedDouble::Boolean else value.class end end |
#recommended_value ⇒ Object
41 42 43 |
# File 'lib/verified_double/method_signature_value.rb', line 41 def recommended_value self.class.new(self.modified_class) end |