module IdPlease module ModelExtensions module ForGroup # 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. 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 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 end end end