Module: IAmICan::Role
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/i_am_i_can/role.rb,
lib/i_am_i_can/role/grouping.rb,
lib/i_am_i_can/role/assignment.rb,
lib/i_am_i_can/role/definition.rb
Defined Under Namespace
Modules: Assignment, Definition, Grouping
Class Method Summary
collapse
Class Method Details
23
24
25
26
27
28
|
# File 'lib/i_am_i_can/role/definition.rb', line 23
def self.(param_roles, i_am_i_can)
roles = param_roles.group_by(&:class)
instances = roles[i_am_i_can.role_model] || []
names = roles.values_at(Symbol, String).flatten.compact.uniq.map(&:to_sym)
[ instances, names ]
end
|
.modeling(objs, i_am_i_can) ⇒ Object
18
19
20
21
|
# File 'lib/i_am_i_can/role/definition.rb', line 18
def self.modeling(objs, i_am_i_can)
return objs if objs.first.is_a?(i_am_i_can.role_model)
objs.map { |obj| i_am_i_can.role_model.where(name: obj).first_or_initialize }
end
|