Created
October 23, 2017 07:21
-
-
Save dmitriy-kiriyenko/2d51518c33f15c1f47869a2a935f82a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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