Module: CanField::CanCan::AbilityAdditions
- Defined in:
- lib/can_field/can_can/ability_additions.rb
Instance Method Summary collapse
-
#abilities_for_subject(subject) ⇒ Object
for internal use.
-
#canf(actions, target, fields, opt_hash = nil, &block) ⇒ Object
see README.md.
Instance Method Details
#abilities_for_subject(subject) ⇒ Object
for internal use
25 26 27 |
# 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) ⇒ Object
see README.md
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# 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 |