Module: Shared::IsData::Pinnable

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/shared/is_data/pinnable.rb

Overview

Shared code pinning objects (adding them to your pinboard).

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) inserted?(user)

Returns true if this item is set to be inserted

Returns:

  • (Boolean)

    true if this item is set to be inserted



28
29
30
# File 'app/models/concerns/shared/is_data/pinnable.rb', line 28

def inserted?(user)
  pinboard_item_for(user).try(:is_inserted)
end

- (PinboardItem?) pinboard_item_for(user)

Returns the pinboard item corresponding to the object, if present

Returns:

  • (PinboardItem, nil)

    the pinboard item corresponding to the object, if present



22
23
24
# File 'app/models/concerns/shared/is_data/pinnable.rb', line 22

def pinboard_item_for(user)
  user.pinboard_items.for_object(self.metamorphosize).first
end

- (Boolean) pinned?(user)

Returns whether the object is pinned by the user

Returns:

  • (Boolean)

    whether the object is pinned by the user



16
17
18
# File 'app/models/concerns/shared/is_data/pinnable.rb', line 16

def pinned?(user)
  user.pinboard_items.for_object(self.metamorphosize).any?
end