Sha256: 4701e08cb9170a6e45cc79c172fcb59c1875d219167a934424f3fde7b0b1f5dd
Contents?: true
Size: 1.64 KB
Versions: 12
Compression:
Stored size: 1.64 KB
Contents
module TheCity class UserAdminPrivilegeList < ApiList include Enumerable # Constructor. # # @param options A hash of options for loading the list. # # Options: # :user_id - The ID of the user to load the admin privileges for. (required) # :page - The page number to get. # :reader - The Reader to use to load the data. # # # Examples: # UserAdminPrivilegeList.new({:user_id => 12345}) # # UserAdminPrivilegeList.new({:user_id => 12345, :page => 2}) # def initialize(options = {}) @options = options @options[:page] ||= 1 @options[:reader] = TheCity::UserAdminPrivilegeListReader.new(@options) if @options[:reader].nil? @json_data = @options[:reader].load_feed @total_entries = @json_data['total_entries'] @total_pages = @json_data['total_pages'] @per_page = @json_data['per_page'] @current_page = @json_data['current_page'] end # Get the specified account admin privilege. # # @param index The index of the admin privilege to get. # # @return [UserAdminPrivilege] def [](index) UserAdminPrivilege.new( @json_data['account_roles'][index] ) if @json_data['account_roles'][index] end # This method is needed for Enumerable. def each &block @json_data['account_roles'].each{ |account_role| yield( UserAdminPrivilege.new(account_role) )} end # Alias the count method alias :size :count # Checks if the list is empty. # # @return True on empty, false otherwise. def empty? @json_data['account_roles'].empty? end end end
Version data entries
12 entries across 12 versions & 1 rubygems