class UserList

Public Class Methods

new(value) click to toggle source
Calls superclass method
# File core/userlist.rb, line 37
def initialize(value)
  type_strict value => Hash
  super(value)
end

Public Instance Methods

add_member(user) click to toggle source
# File core/userlist.rb, line 67
def add_member(user)
  member_update_transaction do
    if user.is_a? User
      member << user
    elsif user.is_a? Integer
      Thread.new {
        user = User.findbyid(user)
        member << user }
    elsif user.is_a? Enumerable
      user.each(&method(:add_member))
    else
      raise ArgumentError.new('UserList member must be User') end end
  self end
member() click to toggle source
# File core/userlist.rb, line 51
def member
  self[:member] ||= Set.new end
member?(user) click to toggle source
# File core/userlist.rb, line 54
def member?(user)
  member.include?(user) if user.is_a? User end
remove_member(user) click to toggle source
# File core/userlist.rb, line 81
def remove_member(user)
  member_update_transaction do
    if user.is_a? User
      member.delete(user)
    elsif user.is_a? Integer
      member.delete(User.findbyid(user))
    elsif user.is_a? Enumerable
      user.map(&remove_member)
    else
      raise ArgumentError.new('UserList member must be User') end end
  self end
user() click to toggle source

リストを所有しているユーザを返す

Return

リストの所有者(User)

# File core/userlist.rb, line 45
def user
  self[:user] end