Created
February 29, 2012 04:14
-
-
Save libryder/1937614 to your computer and use it in GitHub Desktop.
Awesome refactoring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @parent_ou = OrganizationalUnit.where("api_key='#{@api_key}' and api_secret='#{@api_secret}' and master_node=1") | |
| #get first descendents of ou then find all of their children recursively | |
| children = @parent_ou.first.children | |
| ou_children = (children + children.map(&:children)).flatten | |
| #put the children ouid's in a new array | |
| @ous = Array.new | |
| ou_children.each do |child| | |
| @ous.push child.id | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @parent_ou = OrganizationalUnit.where("api_key='#{@api_key}' and api_secret='#{@api_secret}' and master_node=1") | |
| # remove any session data for this user in case of a corrupt session - we're going to set a new one anyway | |
| CakeSession.delete_all(["id = ?", "#{@api_key}#{@api_secret}"]) | |
| #get list of all ou's in organization | |
| lft = @parent_ou.first.lft | |
| rght = @parent_ou.first.rght | |
| @ous = OrganizationalUnit.where("lft >= ? and rght <= ?", lft, rght).map(&:id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment