Namespace
- MODULE Rhino::Resource::ActiveModelExtension
- MODULE Rhino::Resource::ActiveRecordExtension
- MODULE Rhino::Resource::ActiveRecordTree
- MODULE Rhino::Resource::ActiveStorageExtension
- MODULE Rhino::Resource::Describe
- MODULE Rhino::Resource::Owner
- MODULE Rhino::Resource::Params
- MODULE Rhino::Resource::Properties
- MODULE Rhino::Resource::Reference
- MODULE Rhino::Resource::Routing
- MODULE Rhino::Resource::Serialization
- MODULE Rhino::Resource::Sieves
Methods
Included Modules
- Rhino::Resource::Owner
- Rhino::Resource::Properties
- Rhino::Resource::Reference
- Rhino::Resource::Describe
- Rhino::Resource::Routing
- Rhino::Resource::Params
- Rhino::Resource::Serialization
- Rhino::Resource::Sieves
Instance Public methods
display_name()
Link
Source: show
# File rhino/rhino/lib/rhino/resource.rb 34 def display_name 35 return name if respond_to? :name 36 return title if respond_to? :title 37 38 nil 39 end
owner()
Link
Source: show
# File rhino/rhino/lib/rhino/resource.rb 30 def owner 31 send self.class.resource_owned_by 32 end
policy_class()
Link
Source: show
# File rhino/rhino/lib/rhino/resource.rb 43 def policy_class 44 _policy_class 45 end
rhino_policy(policy)
Link
Source: show
# File rhino/rhino/lib/rhino/resource.rb 47 def rhino_policy(policy) 48 self._policy_class = "rhino/#{policy}_policy".classify.constantize 49 end
route_api()
Link
Source: show
# File rhino/rhino/lib/rhino/resource/routing.rb 103 def route_api 104 "#{self.class.route_api}/#{id}" 105 end
route_frontend()
Link
Source: show
# File rhino/rhino/lib/rhino/resource/routing.rb 78 def route_frontend # rubocop:disable Metrics/AbcSize, Metrics/MethodLength 79 base_owner_pk = "#{Rhino.base_owner.table_name}.#{Rhino.base_owner.primary_key}" 80 81 joins = joins_for_base_owner 82 base_owner_id = if joins.empty? 83 # if this is Model is the base owner, we don't to include it in frontend url 84 nil 85 else 86 base_owner_ids = self.class.joins(joins).where(id: id).pluck(base_owner_pk) 87 if base_owner_ids.length != 1 88 # if this Model doesn't have a clear single path to the base owner Model, 89 # we shouldn't include it in the frontend url 90 nil 91 else 92 base_owner_ids.first 93 end 94 end 95 96 if base_owner_id.nil? 97 "#{self.class.route_frontend}/#{id}" 98 else 99 "/#{base_owner_id}#{self.class.route_frontend}/#{id}" 100 end 101 end