Class: Wayfinding::DestinationList

Inherits:
Array
  • Object
show all
Defined in:
lib/wayfinding/destination_list.rb

Overview

The result of Wayfinding.of_kind. An Array of Destination with ability filtering.

Instance Method Summary collapse

Instance Method Details

#accessible_by(ability) ⇒ Object

Destinations the given ability permits. Destinations without an action are excluded: there is nothing to authorize against.



8
9
10
11
12
# File 'lib/wayfinding/destination_list.rb', line 8

def accessible_by(ability)
  self.class.new(select do |destination|
    destination.action && ability.can?(destination.action, destination.subject)
  end)
end