Module: Routable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/routable.rb
Overview
Store object full path in separate table for easy lookup and uniq validation Object must have name and path db fields and respond to parent and parent_changed? methods.
Instance Method Summary collapse
- #build_full_path ⇒ Object
- #full_name ⇒ Object
- #full_path ⇒ Object
- #full_path_components ⇒ Object
-
#owned_by?(user) ⇒ Boolean
Group would override this to check from association.
Instance Method Details
#build_full_path ⇒ Object
81 82 83 84 85 86 87 |
# File 'app/models/concerns/routable.rb', line 81 def build_full_path if parent && path parent.full_path + '/' + path else path end end |
#full_name ⇒ Object
69 70 71 |
# File 'app/models/concerns/routable.rb', line 69 def full_name route&.name || build_full_name end |
#full_path ⇒ Object
73 74 75 |
# File 'app/models/concerns/routable.rb', line 73 def full_path route&.path || build_full_path end |
#full_path_components ⇒ Object
77 78 79 |
# File 'app/models/concerns/routable.rb', line 77 def full_path_components full_path.split('/') end |
#owned_by?(user) ⇒ Boolean
Group would override this to check from association
90 91 92 |
# File 'app/models/concerns/routable.rb', line 90 def owned_by?(user) owner == user end |