Class: RSpec::Contracts::Fulfillment
- Inherits:
-
Object
- Object
- RSpec::Contracts::Fulfillment
- Defined in:
- lib/rspec/contracts/fulfillment.rb
Instance Attribute Summary collapse
-
#interface_fulfillments ⇒ Object
readonly
Returns the value of attribute interface_fulfillments.
Instance Method Summary collapse
- #complete? ⇒ Boolean
- #implementors_for(interface) ⇒ Object
- #incomplete_interfaces ⇒ Object
-
#initialize(interfaces, implementors) ⇒ Fulfillment
constructor
A new instance of Fulfillment.
- #messages_count ⇒ Object
Constructor Details
#initialize(interfaces, implementors) ⇒ Fulfillment
Returns a new instance of Fulfillment.
8 9 10 11 12 13 |
# File 'lib/rspec/contracts/fulfillment.rb', line 8 def initialize(interfaces, implementors) @implementors = implementors @interface_fulfillments = interfaces.map do |interface| InterfaceFulfillment.new interface, implementors_for(interface) end end |
Instance Attribute Details
#interface_fulfillments ⇒ Object (readonly)
Returns the value of attribute interface_fulfillments.
6 7 8 |
# File 'lib/rspec/contracts/fulfillment.rb', line 6 def interface_fulfillments @interface_fulfillments end |
Instance Method Details
#complete? ⇒ Boolean
15 16 17 |
# File 'lib/rspec/contracts/fulfillment.rb', line 15 def complete? incomplete_interfaces.empty? end |
#implementors_for(interface) ⇒ Object
27 28 29 |
# File 'lib/rspec/contracts/fulfillment.rb', line 27 def implementors_for(interface) @implementors.select{ |i| i.interface_names.include? interface.name } end |
#incomplete_interfaces ⇒ Object
19 20 21 |
# File 'lib/rspec/contracts/fulfillment.rb', line 19 def incomplete_interfaces interface_fulfillments.reject(&:complete?) end |
#messages_count ⇒ Object
23 24 25 |
# File 'lib/rspec/contracts/fulfillment.rb', line 23 def interface_fulfillments.map(&:messages_count).inject(&:+) || 0 end |