Module: IdPlease::ModelExtensions::ForGroup

Defined in:
lib/id_please/model_extensions/for_group.rb

Instance Method Summary collapse

Instance Method Details

#children(*args) ⇒ Object

TODO: come up with an object to represent the object here and just return that to the program otherwise we just keep on coming back to edit this.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/id_please/model_extensions/for_group.rb', line 7

def children(*args)
  options = args.extract_options!
  view = options[:view] || :subjects
  valid_views = [:subjects, :subject_hash, :roles, :role_hash, :role_with_assignments, :map]

  raise "Invalid view argument, must be one of #{valid_views}" unless valid_views.include?(view)

  map = IdPlease::AssignmentMap.new(:assignment_class => _auth_assign_class, :subjects => self, :nested => _auth_nested_groups && options[:nested] != false)
  
  map.send(view)
end

#has_role!(role_name, object = nil) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/id_please/model_extensions/for_group.rb', line 19

def has_role!(role_name, object = nil)
  if object && object.kind_of?(self.class) && role_name.to_s == _auth_group_role && self.children.include?(object)
    raise "Attempt to make circular membership loop"
  else
    super
  end
end