Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/protocol/xt.rb
Instance Method Summary collapse
- #conform_to!(protocol) ⇒ Object
-
#conform_to?(protocol) ⇒ Boolean
Returns true if this object conforms to
protocol, otherwise false. -
#Protocol(&block) ⇒ Object
(also: #protocol)
Define a protocol configured by
block.
Instance Method Details
#conform_to!(protocol) ⇒ Object
12 13 14 |
# File 'lib/protocol/xt.rb', line 12 def conform_to!(protocol) extend(protocol) end |
#conform_to?(protocol) ⇒ Boolean
Returns true if this object conforms to protocol, otherwise false.
This is especially useful, if check_failure in the protocol is set to :none or :warning, and conformance of a class to a protocol should be checked later in runtime.
8 9 10 |
# File 'lib/protocol/xt.rb', line 8 def conform_to?(protocol) protocol.check(self, :none) end |
#Protocol(&block) ⇒ Object Also known as: protocol
Define a protocol configured by block. Look at the methods of ProtocolModule to get an idea on how to do that.
18 19 20 |
# File 'lib/protocol/xt.rb', line 18 def Protocol(&block) ProtocolModule.new(&block) end |