can :update, Project do |project|
user.lucky?
endFollowing example is typical in CanCan:
can :update, Project if user.lucky?def editor_store@editor_store ||= CanTango::PermissionEngine::YamlStore.new :editor, path: Rails.root.join('config', 'permits', 'licenses')endWill load a YamlStore from app/config/permits/licenses/editor.ymlYou should then be able to do sth likeeditor_store.permissions # return/execute the permissions from said Yaml Store.Then look into https://github.com/kristianmandrup/cantango/blob/master/lib/cantango/permits/license/rules.rbI think that inside your license you could then do sth like:puts "before: #(permit.ability_rules}"puts "loaded rules: #{editor_store.permissions}"permit.ability_rules.merge! editor_store.permissionsputs "after: #(permit.ability_rules}"Since the editor_store.permissions should return a hash with the rules, it should be possible somehow to achieve sth like this:editor_store.permissions['users'][user.email]In order to load the permissions individually for each user. This would require the permissions loaded to have a top level key matching the user email.Cantango should already support this!Good luck!Let me know if/how you made it work ;) Cheers!
cool thanks so much.
Getting to it.
Well I've one more question Kristian, if you don't mind :D
So, I've license classes with set of rules defined.
Is there a way to set rules in those license class(or elsewhere) via some file(like permission store) or a hash(that could be generated from database) and adding dynamically to the licenses class.
Let me know if i am not clear
Thanks again.
cool thanks so much.
Getting to it.
Well I've one more question Kristian, if you don't mind :D
So, I've license classes with set of rules defined.
Is there a way to set rules in those license class(or elsewhere) via some file(like permission store) or a hash(that could be generated from database) and adding dynamically to the licenses class.
Let me know if i am not clear
Thanks again.
editor = CanTango::PermissionEngine::YamlStore.new :editor, path: Rails.root.join('config', 'permits', 'licenses')is loading the file, but if i do instance.permissions, it returns nil
context 'Loading permissions' dolet (:store) do@store ||= CanTango::PermissionEngine::YamlStore.new 'permissions', :path => config_folderendbefore(:each) dostore.load!endit_should_behave_like "Having permissions"end
shared_examples_for "Having permissions" doit 'should contain bloggers permission allowing to read Comments' dostore.role_groups_permissions['bloggers'].static_rules.can.read.should include('Article')endit 'should contain editors permission allowing to write Posts' dostore.role_groups_permissions['editors'].static_rules.cannot.write.should include('Post')endend