module CanField::CanCan::AbilityAdditions
Public Instance Methods
abilities_for_subject(subject)
click to toggle source
for internal use
# File lib/can_field/can_can/ability_additions.rb, line 25 def abilities_for_subject(subject) @rules.select{|a| a.relevant_for_subject? subject}.map(&:actions).flatten.uniq end
canf(actions, target, fields, opt_hash = nil, &block)
click to toggle source
see README.md
# File lib/can_field/can_can/ability_additions.rb, line 5 def canf(actions, target, fields, opt_hash = nil, &block) unless actions.is_a? Array actions = [actions] end unless fields.is_a? Array fields = [fields] end actions.each do |action| can action.to_sym, target, opt_hash, &block end actions.product(fields).each do |x| action, field = x can "_cf_#{action}_fl_#{field}".to_sym, target, opt_hash, &block end end