Sha256: a9b0d1de5419bbfc482de1b0b8460485a2ca8e941ccc87f6a08c3aaac676e6a8
Contents?: true
Size: 559 Bytes
Versions: 20
Compression:
Stored size: 559 Bytes
Contents
require 'delegate' class ExplicitDelegator < SimpleDelegator def self.enforce_definitions(*methods) define_method(:enforced_methods) do super() | methods end end def initialize(obj) super(obj) ensure_defined end def enforced_methods [] end def ensure_defined missing_methods = [] enforced_methods.each do |method| missing_methods << method unless __getobj__.methods.include?(method) end raise "Methods required to use #{self.class}: #{missing_methods}" unless missing_methods.empty? end end
Version data entries
20 entries across 20 versions & 1 rubygems