mlins (owner)

Revisions

gist: 214570 Download_button fork
public
Public Clone URL: git://gist.github.com/214570.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
      # 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