Module: IAmICan::ResultOf
- Extended by:
- ResultOf
- Includes:
- Permission, Role, RoleGroup
- Included in:
- ResultOf
- Defined in:
- lib/i_am_i_can/helpers/result_of.rb
Defined Under Namespace
Modules: Permission, Role, RoleGroup
Instance Method Summary collapse
Methods included from Permission
Methods included from RoleGroup
Methods included from Role
Instance Method Details
#call(assignment, given, msg_prefix:, fail_msg:, config:) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/i_am_i_can/helpers/result_of.rb', line 52 def call(assignment, given, msg_prefix:, fail_msg:, config:) instances, names = given instances.map!(&:name).map!(&:to_sym) assignment = assignment.map(&:name).map(&:to_sym) unless assignment.first.is_a?(Symbol) to_be_assigned_names = (instances + names).uniq failed_items = to_be_assigned_names - assignment msg = msg_prefix + (assignment.blank? ? 'do nothing' : "#{assignment} DONE") msg << "; And #{failed_items} #{fail_msg}" if failed_items.present? if config.strict_mode && failed_items.present? raise Error, msg else Rails.logger.info(" * #{msg}".green) unless ENV['ITEST'] assignment end end |