Module: IAmICan::Permission::Definition
- Defined in:
- lib/i_am_i_can/permission/definition.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(kls) ⇒ Object
18 19 20 |
# File 'lib/i_am_i_can/permission/definition.rb', line 18 def self.extended(kls) kls.delegate :deconstruct_obj, to: kls end |
Instance Method Details
#deconstruct_obj(obj) ⇒ Object
14 15 16 |
# File 'lib/i_am_i_can/permission/definition.rb', line 14 def deconstruct_obj(obj) i_am_i_can..deconstruct_obj(obj) end |
#have_permission(*actions, obj: nil, remarks: nil) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/i_am_i_can/permission/definition.rb', line 4 def *actions, obj: nil, remarks: nil return unless actions.tap(&:flatten!).first.class.in?([ Symbol, String ]) objs = obj ? Array(obj) : [nil] = actions.product(objs).map { |(p, o)| { action: p, **deconstruct_obj(o), remarks: remarks } } definition = () ResultOf. definition, i_am_i_can, given: .map { |pms| pms.values.compact.join('_').to_sym } end |