Class: Collavre::CreativeShare
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ApplicationRecord
- Collavre::CreativeShare
- Defined in:
- app/models/collavre/creative_share.rb
Class Method Summary collapse
-
.closest_parent_share(ancestor_ids, ancestor_shares) ⇒ Object
Given ancestor_ids and ancestor_shares, returns the closest CreativeShare in the ancestors.
Instance Method Summary collapse
Class Method Details
.closest_parent_share(ancestor_ids, ancestor_shares) ⇒ Object
Given ancestor_ids and ancestor_shares, returns the closest CreativeShare in the ancestors. If there is no ancestor share, returns nil.
34 35 36 |
# File 'app/models/collavre/creative_share.rb', line 34 def self.closest_parent_share(ancestor_ids, ancestor_shares) ancestor_shares.to_a.min_by { |s| ancestor_ids.index(s.creative_id) || Float::INFINITY } end |
Instance Method Details
#sharer_id ⇒ Object
38 39 40 |
# File 'app/models/collavre/creative_share.rb', line 38 def sharer_id shared_by_id || creative.user_id end |