Skip to content

Instantly share code, notes, and snippets.

@oneup
Created October 15, 2009 12:09
Show Gist options
  • Save oneup/210915 to your computer and use it in GitHub Desktop.
Save oneup/210915 to your computer and use it in GitHub Desktop.
rails styles find_by_* automethods
# make on_collision_with()
def self.register_collision_classes
result = instance_methods.grep(/^#{COLLISION_HANDLER_PREFIX}/).map do |method_name|
name_of_handled = method_name[/^#{COLLISION_HANDLER_PREFIX}_?(.*)/,1]
Game.referee.track(self.underscore_name,name_of_handled.empty? ? :any : name_of_handled)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment