mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-30 18:58:39 -04:00
16 lines
452 B
Ruby
16 lines
452 B
Ruby
# frozen_string_literal: true
|
|
|
|
# An ability that answers each permission question once. The cards ask the same
|
|
# few things (can I edit this planting, can I add a photo) of every planting on
|
|
# the page, and CanCan works each answer out from its rules every time.
|
|
class CachedAbility
|
|
def initialize(ability)
|
|
@ability = ability
|
|
@answers = {}
|
|
end
|
|
|
|
def can?(*args)
|
|
@answers.fetch(args) { @answers[args] = @ability.can?(*args) }
|
|
end
|
|
end
|