Sha256: a58c1ec5feb13e69d28c85703ccf693b013b89e458e5c715f6347a6027d1a5cc
Contents?: true
Size: 637 Bytes
Versions: 1
Compression:
Stored size: 637 Bytes
Contents
module Kan class AbilitiesList ROLES_DETECT = 'roles'.freeze def initialize(name, list) @name = name @list = list end def call(*payload) @name == ROLES_DETECT ? mapped_roles(payload) : ability_check(payload) end private def ability_check(payload) @list .select { |abilities| abilities.class.valid_role?(*payload) } .any? { |abilities| abilities.ability(@name).call(*payload) } end def mapped_roles(payload) @list.map do |abilities| abilities.class.valid_role?(*payload) ? abilities.class.role_name : nil end.compact end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kan-0.4.0 | lib/kan/abilities_list.rb |