Module: IAmICan::Role::Definition
- Defined in:
- lib/i_am_i_can/role/definition.rb
Instance Method Summary collapse
Instance Method Details
#have_role(*roles, which_can: [ ], obj: nil, remarks: nil) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/i_am_i_can/role/definition.rb', line 4 def have_role *roles, which_can: [ ], obj: nil, remarks: nil return unless roles.tap(&:flatten!).first.class.in?([ Symbol, String ]) roles.map!(&:to_sym) ; i = i_am_i_can definition = _create_roles(roles.map { |role| { name: role, remarks: remarks } }) Role.modeling(roles, i).each { |r| r.can *which_can, obj: obj, auto_definition: true } if which_can.present? ResultOf.roles definition, i, given: roles end |