Class: Reviewable::Collection
- Inherits:
-
Object
- Object
- Reviewable::Collection
- Defined in:
- lib/reviewable/collection.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Item
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #each ⇒ Object
- #has?(action_id) ⇒ Boolean
-
#initialize(reviewable, guardian, args = nil) ⇒ Collection
constructor
A new instance of Collection.
- #present? ⇒ Boolean
- #to_a ⇒ Object
Constructor Details
#initialize(reviewable, guardian, args = nil) ⇒ Collection
Returns a new instance of Collection.
14 15 16 17 18 19 |
# File 'lib/reviewable/collection.rb', line 14 def initialize(reviewable, guardian, args = nil) args ||= {} @reviewable, @guardian, @args = reviewable, guardian, args @content = [] end |
Instance Method Details
#blank? ⇒ Boolean
25 26 27 |
# File 'lib/reviewable/collection.rb', line 25 def blank? @content.blank? end |
#each ⇒ Object
33 34 35 |
# File 'lib/reviewable/collection.rb', line 33 def each @content.each { |i| yield i } end |
#has?(action_id) ⇒ Boolean
21 22 23 |
# File 'lib/reviewable/collection.rb', line 21 def has?(action_id) @content.any? { |a| a.server_action.to_s == action_id.to_s } end |
#present? ⇒ Boolean
29 30 31 |
# File 'lib/reviewable/collection.rb', line 29 def present? !blank? end |
#to_a ⇒ Object
37 38 39 |
# File 'lib/reviewable/collection.rb', line 37 def to_a @content end |