class DesignByContract::Interface
Attributes
method_specifications[R]
Public Class Methods
new(method_specifications)
click to toggle source
# File lib/design_by_contract/interface.rb, line 2 def initialize(method_specifications) @method_specifications = method_specifications.reduce({}) do |ms, (name, raw_signature)| ms.merge(name => DesignByContract::Signature.new(raw_signature)) end end
Public Instance Methods
==(oth_interface)
click to toggle source
# File lib/design_by_contract/interface.rb, line 30 def ==(oth_interface) return false unless @method_specifications.length == oth_interface.method_specifications.length @method_specifications.each do |name, spec| return false unless oth_interface.method_specifications[name] && oth_interface.method_specifications[name] == spec end return true end
fulfilled_by?(object)
click to toggle source
# File lib/design_by_contract/interface.rb, line 16 def fulfilled_by?(object) @method_specifications.each do |name, signature| return false unless object.respond_to?(name) return false unless signature.match?(object.method(name)) end true end
implemented_by?(implementator_class)
click to toggle source
# File lib/design_by_contract/interface.rb, line 8 def implemented_by?(implementator_class) @method_specifications.each do |name, signature| return false unless implementator_class.method_defined?(name) return false unless signature.match?(implementator_class.instance_method(name)) end true end
match?(method)
click to toggle source
# File lib/design_by_contract/interface.rb, line 24 def match?(method) signature = @method_specifications[method.original_name] signature.match?(method) end
raw()
click to toggle source
# File lib/design_by_contract/interface.rb, line 40 def raw @method_specifications.reduce({}) do |hash, (k,v)| hash.merge(k => v.raw) end end