Skip to content

Instantly share code, notes, and snippets.

@electrical
Created December 31, 2013 13:13
Show Gist options
  • Save electrical/8196598 to your computer and use it in GitHub Desktop.
Save electrical/8196598 to your computer and use it in GitHub Desktop.
def searchin(array, fieldname, searchfor)
if h = array.find { |h|
if h[fieldname].is_a(Array)
l = h[fieldname].find { |l| l[fieldname] == searchfor }
else
h[fieldname] == searchfor
end
}
return h
else
return false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment