Skip to content

Instantly share code, notes, and snippets.

@dmitriy-kiriyenko
Created October 23, 2017 07:21
Show Gist options
  • Save dmitriy-kiriyenko/2d51518c33f15c1f47869a2a935f82a1 to your computer and use it in GitHub Desktop.
Save dmitriy-kiriyenko/2d51518c33f15c1f47869a2a935f82a1 to your computer and use it in GitHub Desktop.
def nested_present?(duck)
if duck.respond_to(:values)
nested_present?(duck.values)
elsif duck.respond_to? :any?
duck.any? { |duckling| nested_present? duckling }
else
duck.present?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment