module Surrounded::Context::NameCollisionDetector::NameCollisionHandler
Private Instance Methods
collision_warnings(role_object_map)
click to toggle source
# File lib/surrounded/context/name_collision_detector.rb, line 27 def collision_warnings(role_object_map) role_object_map.select{|role, object| ![object.methods & role_object_map.keys].flatten.empty? }.map{|role, object| role_collision_message(role,(object.methods & role_object_map.keys).sort) }.join("\n") end
detect_collisions(role_object_map)
click to toggle source
# File lib/surrounded/context/name_collision_detector.rb, line 21 def detect_collisions(role_object_map) if handler handle_collisions(collision_warnings(role_object_map)) end end
handle_collisions(collisions)
click to toggle source
# File lib/surrounded/context/name_collision_detector.rb, line 35 def handle_collisions(collisions) handler_args = [collisions] if handler == :raise handler_args.unshift self.class::NameCollisionError end handler_method.call(*handler_args) end
handler()
click to toggle source
# File lib/surrounded/context/name_collision_detector.rb, line 50 def handler self.class.handler end
handler_method()
click to toggle source
# File lib/surrounded/context/name_collision_detector.rb, line 54 def handler_method if handler.respond_to?(:call) handler elsif respond_to?(handler, true) method(handler) elsif self.class.respond_to?(handler, true) self.class.method(handler) else raise ArgumentError, %{your name collision handler was set to `#{handler}' but there is no instance nor class method of that name} end end
nothing(*)
click to toggle source
# File lib/surrounded/context/name_collision_detector.rb, line 48 def nothing(*); end
role_collision_message(role, colliding_method_names)
click to toggle source
# File lib/surrounded/context/name_collision_detector.rb, line 44 def role_collision_message(role, colliding_method_names) "#{role} has name collisions with #{colliding_method_names}" end