Sha256: 925fd3ea2db37e226e4a8191bd1c3d19be3c407625f1dc9f3ae97cb81c707d73
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
# taxonomite/exceptions.rb module Taxonomite module CreateClassMethod def create(parent, child) new("", parent, child) end end class InvalidChild < RuntimeError extend CreateClassMethod def initialize(msg = "Invalid attempt to add Taxonomite::Node.", parent = nil, child = nil) msg = "Cannot add " + ( child.nil? ? "nil child" : "#{child.name} (#{child.entity_type})" ) + " as child of #{parent.name} (#{parent.entity_type})" unless parent.nil? super(msg) end end class InvalidParent < RuntimeError extend CreateClassMethod def initialize(msg = "Invalid attempt to add Taxonomite::Node.", parent = nil, child = nil) unless (parent.nil? && child.nil?) msg = "Cannot add " + ( child.nil? ? "nil child" : "#{child.name} (#{child.entity_type})" ) + " as child of #{parent.name} (#{parent.entity_type})" unless parent.nil? end super(msg) end end class CircularRelation < RuntimeError extend CreateClassMethod def initialize(msg = "Circular relation in attempt to add Taxonomite::Node.", parent = nil, child = nil) msg = "Circular reference in adding " + ( child.nil? ? "nil child" : "#{child.name} (#{child.entity_type})" ) + " as child of #{parent.name} (#{parent.entity_type})" unless parent.nil? super(msg) end end end # taxonomite
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
taxonomite-0.2.3 | lib/taxonomite/exceptions.rb |