lib/softwear/auth/standard_model.rb in softwear-lib-1.7.7 vs lib/softwear/auth/standard_model.rb in softwear-lib-1.7.8
- old
+ new
@@ -371,10 +371,22 @@
def all
json = validate_response query "all"
objects = JSON.parse(json).map(&method(:new))
objects.each { |u| u.instance_variable_set(:@persisted, true) }
- objects
+ end
+
+ # ====================
+ # Returns array of all users with the given roles
+ # ====================
+ def of_role(*roles)
+ roles = Array(roles)
+ return [] if roles.empty?
+
+ json = validate_response query "ofrole #{roles.split(' ')}"
+
+ objects = JSON.parse(json).map(&method(:new))
+ objects.each { |u| u.instance_variable_set(:@persisted, true) }
end
# ====================
# Given a valid signin token:
# Returns the authenticated user for the given token