Class: Collavre::Label
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ApplicationRecord
- Collavre::Label
- Defined in:
- app/models/collavre/label.rb
Class Method Summary collapse
-
.find_sti_class(type_name) ⇒ Object
Resolve short STI class names to namespaced versions Use constantize to always get fresh class reference after hot reload.
Instance Method Summary collapse
-
#readable_by?(user) ⇒ Boolean
Check if user has permission to read this label If linked to a Creative, delegates to Creative’s permission system Otherwise falls back to owner-based or public (nil owner) visibility.
Class Method Details
.find_sti_class(type_name) ⇒ Object
Resolve short STI class names to namespaced versions Use constantize to always get fresh class reference after hot reload
19 20 21 22 |
# File 'app/models/collavre/label.rb', line 19 def self.find_sti_class(type_name) type_name = "Collavre::#{type_name}" unless type_name.start_with?("Collavre::") type_name.constantize end |
Instance Method Details
#readable_by?(user) ⇒ Boolean
Check if user has permission to read this label If linked to a Creative, delegates to Creative’s permission system Otherwise falls back to owner-based or public (nil owner) visibility
29 30 31 32 33 34 35 36 37 |
# File 'app/models/collavre/label.rb', line 29 def readable_by?(user) return true if owner_id.present? && owner_id == user&.id if creative_id.present? && creative creative.(user, :read) else owner_id.nil? end end |