Methods
C
T
U
Included Modules
Instance Public methods
check_owner_reference(resource)
    # File rhino/rhino/lib/rhino/engine.rb
105 def check_owner_reference(resource)
106   return if unowned?(resource)
107 
108   # If its in the list, we're good
109   return if top_level_references(resource).include?(resource.resource_owned_by)
110 
111   raise "#{resource} does not have a reference to its owner #{resource.resource_owned_by}"
112 end
check_owner_reflections()
   # File rhino/rhino/lib/rhino/engine.rb
83 def check_owner_reflections
84   raise "#{Rhino.base_owner} must have reflection for #{Rhino.auth_owner}" if Rhino.base_to_auth.nil?
85 
86   raise "#{Rhino.auth_owner} must have reflection for #{Rhino.base_owner}" if Rhino.auth_to_base.nil?
87 end
check_ownership(resource)
   # File rhino/rhino/lib/rhino/engine.rb
89 def check_ownership(resource)
90   return if unowned?(resource)
91 
92   raise "#{resource} does not have rhino ownership set" unless resource.resource_owned_by.present?
93 end
check_references(resource)
    # File rhino/rhino/lib/rhino/engine.rb
 95 def check_references(resource)
 96   # Some resource types don't have reflections
 97   top_level_reflections = resource.try(:reflections)&.keys&.map(&:to_sym) || []
 98 
 99   # All references should have a reflection
100   delta = top_level_references(resource) - top_level_reflections
101 
102   raise "#{resource} has references #{delta} that do not exist as associations" if delta.present?
103 end
check_resources()
    # File rhino/rhino/lib/rhino/engine.rb
114 def check_resources
115   check_owner_reflections
116 
117   Rhino.resource_classes.each do |resource|
118     check_ownership(resource)
119     check_references(resource)
120     check_owner_reference(resource) if resource.ancestors.include?(Rhino::Resource::ActiveRecordExtension)
121   end
122 end
top_level_references(resource)
   # File rhino/rhino/lib/rhino/engine.rb
69 def top_level_references(resource)
70   # Handle things like rhino_references [{ blog_post: [:blog] }]
71   # Just check the top level ones for now
72   resource.references.flat_map { |ref| ref.is_a?(Hash) ? ref.keys : ref }
73 end
unowned?(resource)
   # File rhino/rhino/lib/rhino/engine.rb
75 def unowned?(resource)
76   # Special case
77   return true if resource.ancestors.include?(Rhino::Resource::ActiveStorageExtension)
78 
79   # Owners are not themselves owned
80   resource.auth_owner? || resource.base_owner? || resource.global_owner?
81 end