Created
August 25, 2016 15:01
-
-
Save lightman76/53832347f145cfdc65394c617b40ea6e to your computer and use it in GitHub Desktop.
Proposed modification to the attribute? method of the attributes module to use the unobservable_read_attribute when available
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 attribute?(key) | |
# this method is used only for conditional type access. | |
# When included on an object with read observations, don't count this as an observable read | |
if respond_to? :unobservable_read_attribute | |
value = unobservable_read_attribute key | |
else | |
value = read_attribute key | |
end | |
return false if value.nil? | |
return false if value.respond_to?(:empty?) && value.empty? | |
value.to_s !~ /^(false|no|never)$/i | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment