Skip to content

Instantly share code, notes, and snippets.

@sxross
Created January 4, 2010 04:32
Show Gist options
  • Save sxross/268302 to your computer and use it in GitHub Desktop.
Save sxross/268302 to your computer and use it in GitHub Desktop.
module FindOrCreate
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
module ClassMethods
def find_or_create(arg)
first(arg) || create(arg)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment