Sha256: d6b772df7f15113c24956b99d230cf5cc0a4e83e795cde229cab73462cf4f18d
Contents?: true
Size: 787 Bytes
Versions: 11
Compression:
Stored size: 787 Bytes
Contents
module Copyable class DeclarationChecker def verify!(declaration_block) @declarations_that_were_called = [] self.instance_eval(&declaration_block) Copyable::Declarations::ALL.each do |declaration| if declaration.required? && !@declarations_that_were_called.include?(declaration.method_name) message = "The copyable declaration must include #{declaration.name}." raise DeclarationError.new(message) end end end def method_missing(method_name, *args, &block) method = method_name.to_s if Copyable::Declarations.include?(method) @declarations_that_were_called << method else raise DeclarationError.new("Unknown declaration '#{method}' in copyable.") end end end end
Version data entries
11 entries across 11 versions & 1 rubygems