Meteor.methods({
  "createAdminRoleIfNotDefined": function () {
    // TODO: Refactor this process to allow user to specify  admin role as parameter
    // E.g. a config page where the user can input the desired string

    // Define the admin role
    var adminRole = 'admin';

    // Placeholder variable for admin check
    var adminIsDefined;

    // Get all existing roles
    var roles = Roles.getAllRoles().fetch();

    // Flatten the roles to an array of role names
    var roleNames = _.map(roles, function (role) {
      // Return the name of the role
      return role.name;
    });

    // Check if admin role is defined in Roles collection
    adminIsDefined = _.contains(roleNames, adminRole);

    // Create the admin role if it is not already defined
    if (!adminIsDefined) {
      console.log('Defining "' + adminRole + '" role.');
      Roles.createRole(adminRole);
    }
  }
});

@@ -23,13 +23,8 @@
 eate
-Admin
 Role
@@ -28,23 +28,24 @@
 oleIfNot
-Defined
+Existing
 %22: funct
@@ -49,16 +49,24 @@
 nction (
+roleName
 ) %7B%0A    
@@ -70,216 +70,90 @@
    /
-/ TODO: Refactor this process to allow user to specify  admin role as parameter%0A    // E.g. a config page where the user can input the desired string%0A%0A    // Define the admin role%0A    var adminRole = 'admin';
+*%0A    Check if a given role exists%0A    create the role if it doesn't exist%0A    */%0A
 %0A%0A  
@@ -182,21 +182,20 @@
 ble for 
-admin
+role
  check%0A 
@@ -201,30 +201,26 @@
     var 
-adminIsDefined
+roleExists
 ;%0A%0A    /
@@ -264,25 +264,25 @@
 s = 
-Roles.getAllRoles
+Meteor.roles.find
 ().f
@@ -524,30 +524,26 @@
 ion%0A    
-adminIsDefined
+roleExists
  = _.con
@@ -559,24 +559,23 @@
 eNames, 
-adminRol
+roleNam
 e);%0A%0A   
@@ -642,22 +642,18 @@
 f (!
-adminIsDefined
+roleExists
 ) %7B%0A
@@ -685,24 +685,23 @@
 ng %22' + 
-adminRol
+roleNam
 e + '%22 r
@@ -735,16 +735,15 @@
 ole(
-adminRol
+roleNam
 e);%0A

Refactor to create role if not existing