class Hipmost::Hipchat::UserRepository
Attributes
users[RW]
Public Class Methods
load_from(path)
click to toggle source
# File lib/hipmost/hipchat/user_repository.rb, line 12 def self.load_from(path) new(path).tap(&:load) end
new(path)
click to toggle source
# File lib/hipmost/hipchat/user_repository.rb, line 16 def initialize(path) @path = Pathname.new(path).join("users.json") @users = {} @name_index = {} end
Public Instance Methods
file_data()
click to toggle source
# File lib/hipmost/hipchat/user_repository.rb, line 33 def file_data File.read(@path) end
load(data = file_data)
click to toggle source
# File lib/hipmost/hipchat/user_repository.rb, line 22 def load(data = file_data) json = JSON.load(data) json.each do |user_obj| user = user_obj["User"] user_obj = User.new(user) @users[user["id"]] = user_obj @name_index[user_obj.username] = user["id"] end end