lib/contextio/api/resource_collection.rb in contextio-1.2.4 vs lib/contextio/api/resource_collection.rb in contextio-1.3.0
- old
+ new
@@ -118,10 +118,13 @@
# @!attribute [r] associations_hash
# @return [Hash{Symbol => Resource}] A hash of association names to the
# associated resource of that type.
def associations_hash
@associations_hash ||= self.class.associations.inject({}) do |memo, association_name|
- memo[association_name.to_sym] = self.send(association_name)
+ if (association = self.send(association_name))
+ memo[association_name.to_sym] = association
+ end
+
memo
end
end
# Make sure a ResourceCollection has the declarative syntax handy.