Class: DesignByContract::Signature
- Inherits:
-
Object
- Object
- DesignByContract::Signature
- Defined in:
- lib/design_by_contract/signature.rb
Defined Under Namespace
Classes: Spec
Instance Method Summary collapse
- #==(oth_signature) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(raw_method_specs) ⇒ Signature
constructor
A new instance of Signature.
- #match?(parametered_object) ⇒ Boolean
- #raw ⇒ Object
- #valid?(*args) ⇒ Boolean
Constructor Details
#initialize(raw_method_specs) ⇒ Signature
Returns a new instance of Signature.
4 5 6 7 8 |
# File 'lib/design_by_contract/signature.rb', line 4 def initialize(raw_method_specs) @method_args_specs = raw_method_specs.map do |spec| DesignByContract::Signature::Spec.new(spec) end end |
Instance Method Details
#==(oth_signature) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/design_by_contract/signature.rb', line 21 def ==(oth_signature) return false unless method_args_specs.length == oth_signature.method_args_specs.length method_args_specs.each_with_index do |spec, index| return false unless spec == oth_signature.method_args_specs[index] end true end |
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/design_by_contract/signature.rb', line 31 def empty? method_args_specs.empty? end |
#match?(parametered_object) ⇒ Boolean
17 18 19 |
# File 'lib/design_by_contract/signature.rb', line 17 def match?(parametered_object) parameters_match?(parametered_object.parameters) end |
#raw ⇒ Object
35 36 37 |
# File 'lib/design_by_contract/signature.rb', line 35 def raw @method_args_specs.map(&:raw) end |
#valid?(*args) ⇒ Boolean
10 11 12 13 14 15 |
# File 'lib/design_by_contract/signature.rb', line 10 def valid?(*args) method_args_specs.each_with_index do |spec, index| return false unless spec.interface.fulfilled_by?(args[index]) end return true end |