Method: Protocol::ProtocolModule#inherit
- Defined in:
- lib/protocol/protocol_module.rb
#inherit(modul, methodname, block_expected = nil) ⇒ Object
Inherit a method signature from an instance method named methodname of modul. This means that this protocol should understand these instance methods with their arity and block expectation. Note that automatic detection of blocks does not work for Ruby methods defined in C. You can set the block_expected argument if you want to do this manually.
234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/protocol/protocol_module.rb', line 234 def inherit(modul, methodname, block_expected = nil) Module === modul or raise TypeError, "expected Module not #{modul.class} as modul argument" methodnames = methodname.respond_to?(:to_ary) ? methodname.to_ary : [ methodname ] methodnames.each do |methodname| m = parse_instance_method_signature(modul, methodname) block_expected and m.block_expected = block_expected @descriptor. m end self end |