Class: VerifiedDouble::MethodSignature
- Inherits:
-
Object
- Object
- VerifiedDouble::MethodSignature
- Defined in:
- lib/verified_double/method_signature.rb,
lib/verified_double/method_signature/value.rb,
lib/verified_double/method_signature/class_value.rb,
lib/verified_double/method_signature/boolean_value.rb,
lib/verified_double/method_signature/instance_value.rb,
lib/verified_double/method_signature/rspec_double_value.rb
Direct Known Subclasses
Defined Under Namespace
Classes: BooleanValue, ClassValue, InstanceValue, RspecDoubleValue, Value
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#method ⇒ Object
Returns the value of attribute method.
-
#method_operator ⇒ Object
Returns the value of attribute method_operator.
-
#return_values ⇒ Object
Returns the value of attribute return_values.
Instance Method Summary collapse
- #belongs_to?(other) ⇒ Boolean
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(attributes = {}) ⇒ MethodSignature
constructor
A new instance of MethodSignature.
- #recommended_verified_signature ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ MethodSignature
Returns a new instance of MethodSignature.
5 6 7 8 9 |
# File 'lib/verified_double/method_signature.rb', line 5 def initialize(attributes = {}) attributes.each do |name, value| self.send "#{name}=", value end end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
3 4 5 |
# File 'lib/verified_double/method_signature.rb', line 3 def args @args end |
#class_name ⇒ Object
Returns the value of attribute class_name.
3 4 5 |
# File 'lib/verified_double/method_signature.rb', line 3 def class_name @class_name end |
#method ⇒ Object
Returns the value of attribute method.
3 4 5 |
# File 'lib/verified_double/method_signature.rb', line 3 def method @method end |
#method_operator ⇒ Object
Returns the value of attribute method_operator.
3 4 5 |
# File 'lib/verified_double/method_signature.rb', line 3 def method_operator @method_operator end |
#return_values ⇒ Object
Returns the value of attribute return_values.
3 4 5 |
# File 'lib/verified_double/method_signature.rb', line 3 def return_values @return_values end |
Instance Method Details
#belongs_to?(other) ⇒ Boolean
11 12 13 14 15 16 17 18 19 |
# File 'lib/verified_double/method_signature.rb', line 11 def belongs_to?(other) self.class_name == other.class_name && self.method_operator == other.method_operator && self.method == other.method && self.args.size == other.args.size && (0 ... args.size).all?{|i| self.args[i].belongs_to?(other.args[i]) } && self.return_values.size == other.return_values.size && (0 ... return_values.size).all?{|i| self.return_values[i].belongs_to?(other.return_values[i]) } end |
#eql?(other) ⇒ Boolean
25 26 27 |
# File 'lib/verified_double/method_signature.rb', line 25 def eql?(other) to_s.eql?(other.to_s) end |
#hash ⇒ Object
29 30 31 |
# File 'lib/verified_double/method_signature.rb', line 29 def hash to_s.hash end |
#recommended_verified_signature ⇒ Object
33 34 35 36 37 38 |
# File 'lib/verified_double/method_signature.rb', line 33 def recommended_verified_signature self.clone.tap do |result| result.args = result.args.map{|arg| arg.recommended_value } result.return_values = result.return_values.map{|return_value| return_value.recommended_value } end end |
#to_s ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/verified_double/method_signature.rb', line 44 def to_s args_string = args.map(&:content).map{|v| v || 'nil'}.join(', ') return_values_string = return_values.map(&:content).map{|v| v || 'nil'}.join(', ') return_values_string = nil if return_values_string.empty? result = [ "#{class_name}#{method_operator}#{method}(#{args_string})", return_values_string] result.flatten.compact.join("=>") end |