Sha256: fd7bd768a4a0e5427c555a4e89e2e9cbe4da07c3f8f6c5e118d814f8a3d36c04
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
class GeneralAbility include CanCan::Ability def initialize(user) if alpha?(user) can :manage, :hubspot end if beta?(user) end if in_country?(user,'Argentina') can :manage, :derose_events can :manage, :office_argentina end can :manage, :notion can :manage, :asana_com can :see, :mailchimp if petal_enabled?(user,'mailchimp') can :configure, :mailchimp end end private def in_country?(user,country_name) name = user.current_account.try(:name) if name @country = Rails.cache.fetch("countryfor#{name}") do padma_account(user).try(:country) end @country == country_name end end def padma_account(user) if user.current_account.respond_to?(:padma) user.current_account.padma else user.current_account end end def petal_enabled?(user,petal_name) petal_name.in?(padma_account(user).enabled_petals||[]) end def alpha?(user) user.account_tester_level == 'alpha' end def beta?(user) tl = user.account_tester_level tl == 'alpha' || tl == 'beta' end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
padma-assets-0.3.6 | app/abilities/general_ability.rb |
padma-assets-0.3.5 | app/abilities/general_ability.rb |
padma-assets-0.3.4 | app/abilities/general_ability.rb |