Module: Routable

Extended by:
ActiveSupport::Concern
Included in:
Namespace, Project
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

Instance Method Details

#build_full_pathObject


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_nameObject


69
70
71
# File 'app/models/concerns/routable.rb', line 69

def full_name
  route&.name || build_full_name
end

#full_pathObject


73
74
75
# File 'app/models/concerns/routable.rb', line 73

def full_path
  route&.path || build_full_path
end

#full_path_componentsObject


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

Returns:

  • (Boolean)

90
91
92
# File 'app/models/concerns/routable.rb', line 90

def owned_by?(user)
  owner == user
end