Class | Selectable::Tags |
In: |
lib/selectable/tags.rb
|
Parent: | ::Hash |
An example of filtering an Array of tagged objects based on a provided Hash of tags or Array of tag values. obj in this case would be an object that includes Taggable.
class Something def [](tags={}) tags = [tags].flatten unless tags.is_a?(Hash) self.select do |obj| obj.tags >= tags end end end