Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This module hides the implementation details that
- # relationships are stored in a hash, which is bound to change anyway.
- # Also, it allows to *fail fast* when trying to access a relationship
- # that is not defined in a model (via the relationship! method)
- module RelationshipAccess
- def relationship(name, repository_name = default_repository_name)
- relationships(repository_name)[name]
- end
- def relationship!(name, repository_name = default_repository_name)
- unless relationship = relationship(name, repository_name)
- raise(ArgumentError, "No relationship #{name.inspect} for #{self.name} in #{repository_name}")
- end
- relationship
- end
- end
Add Comment
Please, Sign In to add comment