Sha256: aba07b15bcc507f7eed549960dee68ceb6c1f754e5e0391eb64d997fef89406a
Contents?: true
Size: 704 Bytes
Versions: 3
Compression:
Stored size: 704 Bytes
Contents
module IAmICan module Permission module Definition def have_permission *actions, obj: nil permissions = actions.product(Array[obj]).map { |(p, o)| { action: p, **deconstruct_obj(o) } } definition = _create_permissions(permissions) ResultOf.roles definition, i_am_i_can, given: permissions.map { |pms| pms.values.compact.join('_').to_sym } end %i[ have_permissions has_permission has_permissions ].each { |aname| alias_method aname, :have_permission } def deconstruct_obj(obj) i_am_i_can.permission_model.deconstruct_obj(obj) end def self.extended(kls) kls.delegate :deconstruct_obj, to: kls end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
i_am_i_can-4.2.0 | lib/i_am_i_can/permission/definition.rb |
i_am_i_can-4.1.0 | lib/i_am_i_can/permission/definition.rb |
i_am_i_can-4.0.0 | lib/i_am_i_can/permission/definition.rb |