Class: Proton::Set
- Inherits:
-
Array
- Object
- Array
- Proton::Set
- Defined in:
- lib/proton/set.rb
Instance Method Summary collapse
-
#except(by = {}) ⇒ Object
Method: except (Proton::Set) Filters a set by removing items matching the given metadata criteria.
-
#find(by = {}) ⇒ Object
Method: find (Proton::Set) Filters a set by given metadata criteria.
Instance Method Details
#except(by = {}) ⇒ Object
Method: except (Proton::Set) Filters a set by removing items matching the given metadata criteria.
This is the opposite of find.
## Example
Page['/'].children.find(layout: 'default')
26 27 28 29 30 |
# File 'lib/proton/set.rb', line 26 def except(by={}) self.class.new(reject do |page| by.inject(true) { |b, (field, value)| b &&= (page..send(field) == value) } end) end |
#find(by = {}) ⇒ Object
Method: find (Proton::Set) Filters a set by given metadata criteria.
## Example
Page['/'].children.find(layout: 'default')
12 13 14 15 16 |
# File 'lib/proton/set.rb', line 12 def find(by={}) self.class.new(select do |page| by.inject(true) { |b, (field, value)| b &&= (page..send(field) == value) } end) end |