class Copyable::DeclarationChecker

Public Instance Methods

method_missing(method_name, *args, &block) click to toggle source
# File lib/copyable/syntax_checking/declaration_checker.rb, line 16
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
verify!(declaration_block) click to toggle source
# File lib/copyable/syntax_checking/declaration_checker.rb, line 4
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