Sha256: 3685ed2be59b70d386d56148ae9fc83acfd5c2377ea85599689c95ade58958f1
Contents?: true
Size: 537 Bytes
Versions: 18
Compression:
Stored size: 537 Bytes
Contents
class ExplicitDelegator < SimpleDelegator 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 def self.enforce_definitions(*methods) define_method(:enforced_methods) do return methods end end end
Version data entries
18 entries across 18 versions & 1 rubygems