Method: Strongbolt::Capability.to_hash

Defined in:
lib/strongbolt/capability.rb

.to_hashObject

Group by model, ownership and tenant access and tells whether each action is set or not in a hash


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/strongbolt/capability.rb', line 86

def self.to_hash
  hash = {}
  all.ordered.each do |capability|
    key = {
      model: capability.model,
      require_ownership: capability.require_ownership,
      require_tenant_access: capability.require_tenant_access
    }

    hash[key] ||= {
      find: false,
      create: false,
      update: false,
      destroy: false
    }

    hash[key][capability.action.to_sym] = true
  end
  hash
end