Properly define accessor methods for nil attributes

This pull request adds a test and code to handle cases where an attribute has a null value. After this change, calling `resource.attr` will return `nil`, instead of raising an exception. LMK if this is desired behavior.