Class: Finitio::Contract
- Inherits:
-
Object
- Object
- Finitio::Contract
- Includes:
- Metadata
- Defined in:
- lib/finitio/support/contract.rb
Constant Summary
Constants included from Metadata
Instance Attribute Summary collapse
-
#dresser ⇒ Object
readonly
Returns the value of attribute dresser.
-
#infotype ⇒ Object
readonly
Returns the value of attribute infotype.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#undresser ⇒ Object
readonly
Returns the value of attribute undresser.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #bind_ruby_type(clazz) ⇒ Object
- #hash ⇒ Object
-
#initialize(infotype, dresser, undresser, name = nil, metadata = nil) ⇒ Contract
constructor
A new instance of Contract.
- #resolve_proxies(system) ⇒ Object
- #unconstrained ⇒ Object
Methods included from Metadata
#metadata, #metadata=, #metadata?
Constructor Details
#initialize(infotype, dresser, undresser, name = nil, metadata = nil) ⇒ Contract
Returns a new instance of Contract.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/finitio/support/contract.rb', line 5 def initialize(infotype, dresser, undresser, name = nil, = nil) unless infotype.is_a?(Type) raise ArgumentError, "Type expected, got `#{infotype}`" end unless dresser.respond_to?(:call) raise ArgumentError, "r(:call) expected, got `#{dresser}`" end unless undresser.respond_to?(:call) raise ArgumentError, "r(:call) expected, got `#{undresser}`" end unless name.nil? or name.is_a?(Symbol) raise ArgumentError, "Symbol expected, got `#{name}`" end @name = name @infotype = infotype @dresser = dresser @undresser = undresser @metadata = end |
Instance Attribute Details
#dresser ⇒ Object (readonly)
Returns the value of attribute dresser.
25 26 27 |
# File 'lib/finitio/support/contract.rb', line 25 def dresser @dresser end |
#infotype ⇒ Object (readonly)
Returns the value of attribute infotype.
25 26 27 |
# File 'lib/finitio/support/contract.rb', line 25 def infotype @infotype end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/finitio/support/contract.rb', line 25 def name @name end |
#undresser ⇒ Object (readonly)
Returns the value of attribute undresser.
25 26 27 |
# File 'lib/finitio/support/contract.rb', line 25 def undresser @undresser end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
36 37 38 39 40 41 42 43 44 |
# File 'lib/finitio/support/contract.rb', line 36 def ==(other) super || ( other.is_a?(Contract) && name == other.name && infotype == other.infotype && dresser == other.dresser && undresser == other.undresser ) end |
#bind_ruby_type(clazz) ⇒ Object
27 28 29 30 |
# File 'lib/finitio/support/contract.rb', line 27 def bind_ruby_type(clazz) @dresser = clazz.method(name.to_sym) @undresser = clazz.instance_method(:"to_#{name}") end |
#hash ⇒ Object
32 33 34 |
# File 'lib/finitio/support/contract.rb', line 32 def hash infotype.hash ^ dresser.hash ^ undresser.hash end |