Module: BookmarkSystem::Bookmarker

Extended by:
ActiveSupport::Concern
Defined in:
lib/bookmark_system/bookmarker.rb

Overview

Bookmarker module

This module defines bookmarker behavior in bookmark system

Instance Method Summary collapse

Instance Method Details

#bookmark(bookmarkee) ⇒ Boolean

Creates a BookmarkSystem::Bookmark relationship between self and a BookmarkSystem::Bookmarkee object

Parameters:

Returns:

  • (Boolean)


43
44
45
# File 'lib/bookmark_system/bookmarker.rb', line 43

def bookmark(bookmarkee)
  Bookmark.bookmark(self, bookmarkee)
end

#bookmarkees_by(klass) ⇒ ActiveRecord::Relation

Retrieves a scope of BookmarkSystem::Bookmark objects that are bookmarked by self

Parameters:

  • klass (Class)
    • the Class to include

Returns:

  • (ActiveRecord::Relation)


83
84
85
# File 'lib/bookmark_system/bookmarker.rb', line 83

def bookmarkees_by(klass)
  Bookmark.scope_by_bookmarker(self).scope_by_bookmarkee_type(klass)
end

#bookmarks?(bookmarkee) ⇒ Boolean

Specifies if self bookmarks a BookmarkSystem::Bookmarker object

Parameters:

Returns:

  • (Boolean)


73
74
75
# File 'lib/bookmark_system/bookmarker.rb', line 73

def bookmarks?(bookmarkee)
  Bookmark.bookmarks?(self, bookmarkee)
end

#is_bookmarker?Boolean

Specifies if self can bookmark BookmarkSystem::Bookmarkee objects

Returns:

  • (Boolean)


33
34
35
# File 'lib/bookmark_system/bookmarker.rb', line 33

def is_bookmarker?
  true
end

#toggle_bookmark(bookmarkee) ⇒ Boolean

Toggles a BookmarkSystem::Bookmark relationship between self and a BookmarkSystem::Bookmarkee object

Parameters:

Returns:

  • (Boolean)


63
64
65
# File 'lib/bookmark_system/bookmarker.rb', line 63

def toggle_bookmark(bookmarkee)
  Bookmark.toggle_bookmark(self, bookmarkee)
end

#unbookmark(bookmarkee) ⇒ Boolean

Destroys a BookmarkSystem::Bookmark relationship between self and a BookmarkSystem::Bookmarkee object

Parameters:

Returns:

  • (Boolean)


53
54
55
# File 'lib/bookmark_system/bookmarker.rb', line 53

def unbookmark(bookmarkee)
  Bookmark.unbookmark(self, bookmarkee)
end