Created
October 20, 2009 20:11
-
-
Save mlins/214570 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
# Returns model class used by parent side of the relationship | |
# | |
# @return [Resource] | |
# Class of association parent | |
# | |
# @api private | |
def parent_model | |
@parent_model ||= (@child_model || Object).find_const(parent_model_name) | |
rescue NameError | |
raise NameError, "Cannot find the parent_model #{parent_model_name} for #{child_model_name} in #{name}" | |
end | |
# TODO: document | |
# @api private | |
def parent_model? | |
parent_model | |
true | |
rescue NameError | |
false | |
end | |
# TODO: document | |
# @api private | |
def parent_model_name | |
@parent_model ? parent_model.name : @parent_model_name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment