Sha256: 55d1e98a9b2b8183a7c896c24a38b0eaddc75ce7e811a9889ec55b1ef6d89940
Contents?: true
Size: 928 Bytes
Versions: 1
Compression:
Stored size: 928 Bytes
Contents
module Tins module Implement MESSAGES = { default: 'method %{method_name} not implemented in module %{module}', subclass: 'method %{method_name} has to be implemented in '\ 'subclasses of %{module}', submodule: 'method %{method_name} has to be implemented in '\ 'submodules of %{module}', } def implement(method_name, msg = :default) case msg when ::Symbol msg = MESSAGES.fetch(msg) when ::Hash return implement method_name, msg.fetch(:in) end begin msg = msg % { method_name: method_name, module: self } rescue KeyError end define_method(method_name) do |*| raise ::NotImplementedError, msg end end def implement_in_submodule(method_name) implement method_name, 'method %{method_name} has to be implemented in submodules of'\ ' %{module}' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tins-1.4.1 | lib/tins/implement.rb |