Class: Workarea::User::AdminBookmark

Inherits:
Object
  • Object
show all
Includes:
ApplicationDocument
Defined in:
app/models/workarea/user/admin_bookmark.rb

Class Method Summary collapse

Methods included from ApplicationDocument

#releasable?

Methods included from Sidekiq::Callbacks

add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list

Methods included from Mongoid::Document

#embedded_children

Class Method Details

.bookmarked?(user, path) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/workarea/user/admin_bookmark.rb', line 20

def self.bookmarked?(user, path)
  by_user(user).where(path: sanitize_path(path)).count > 0
end

.sanitize_path(path) ⇒ Object



24
25
26
27
28
29
30
31
# File 'app/models/workarea/user/admin_bookmark.rb', line 24

def self.sanitize_path(path)
  parsed = URI.parse(path)

  result = [parsed.path, parsed.query].join('?')
  result = "/#{result}" unless result.starts_with?('/')
  result = result[0..-2] if result.ends_with?('?')
  result
end