Sha256: 613566ff8dbc0790a8acdc7d1ad7c707e0ff110ab23f0f3852df5c08f1be025c
Contents?: true
Size: 1017 Bytes
Versions: 4
Compression:
Stored size: 1017 Bytes
Contents
module CanTango::Api module Can module Account include CanTango::Api::Ability::Account # Example: generated from types of accounts! (see below) # def admin_account_can?(*args) # current_account_ability(:admin).can?(*args) # end def self.included(base) ::CanTango.config.accounts.registered.each do |account| # by default alias call to current_xxx_account to current_xxx (devise user method) unless already defined! unless base.methods.include? :"current_#{account}_account" define_method :"current_#{account}_account" do send :"current_#{account}" end end base.class_eval %{ def #{account}_account_can? *args current_account_ability(:#{account}).can?(*args) end def #{account}_account_cannot? *args current_account_ability(:#{account}).cannot?(*args) end } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems