Exception: DRP::DRPNameClashError

Inherits:
DRPError
  • Object
show all
Defined in:
lib/error.rb

Constant Summary collapse

CLASHING_INSTANCE_METHODS =
%w{
  # default_rule_method 
  # next_codon
  # next_meta_codon
  depth
  max_depth
  map
}
CLASHING_CLASS_METHODS =
%w{
  begin_rules
  end_rules
  max_depth
  weight
  weight_fcd
}

Class Method Summary collapse

Class Method Details

.test(extended_klass) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/error.rb', line 45

def self.test extended_klass
  k = extended_klass
  CLASHING_INSTANCE_METHODS.each do |m|
    if k.method_defined?(m) or k.protected_method_defined?(m) or k.private_method_defined?(m)
      raise(
        self,
        "the class you are extending already defines instance method '#{m}'",
        caller
      )
    end
  end
  class_methods = k.methods + k.protected_methods + k.private_methods
  CLASHING_CLASS_METHODS.each do |name|
    if class_methods.include? name
      raise(
        self,
        "the class you are extending already defines class method #{name}",
        caller
      )
    end
  end
end