lib/cantango/permits/permit.rb in cantango-0.8.5.1 vs lib/cantango/permits/permit.rb in cantango-0.8.6

- old
+ new

@@ -28,16 +28,18 @@ end # executes the permit def execute executor.execute! + ability_sync! end def category label config.models.by_category label end + def any reg_exp config.models.by_reg_exp reg_exp end def options @@ -70,15 +72,20 @@ def user_account ability.user_account end - def rules - ability.send :rules + def ability_rules + ability.send(:rules) end - # In a specific Role based Permit you can use + def ability_sync! + ability_rules << (rules - ability_rules) + ability_rules.flatten! + end + + # In a specific Role based Permit you can use # def permit? user, options = {} # return if !super(user, :in_role) # ... permission logic follows # # This will call the Permit::Base#permit? instance method (the method below) @@ -101,11 +108,11 @@ names.to_strings.each do |name| try_license name end end - include CanTango::Rules + include CanTango::Rules # also makes a Permit a subclass of CanCan::Ability protected def try_license name module_name = "#{name.camelize}License" @@ -115,10 +122,10 @@ raise "License #{module_name} is not defined" rescue raise "License #{clazz} could not be enforced using #{self.inspect}" end - # This method will contain the actual rules + # This method will contain the actual rules # can be implemented in the subclass def permit_rules end