class Yapt::Member

Attributes

membership[R]

Public Class Methods

all() click to toggle source
# File lib/yapt/member.rb, line 22
def self.all
  @memberships ||= cache[:results]
end
cache() click to toggle source
# File lib/yapt/member.rb, line 26
def self.cache
  if File.exists?(Yapt.tracker_member_cache)
    cache = YAML.load_file(Yapt.tracker_member_cache)
  end
  expires_at = cache ? cache[:expires_at] : Time.new(0)
  expires_at > Time.now ? cache : generate_cache
end
find(id) click to toggle source
# File lib/yapt/member.rb, line 5
def self.find(id)
  new (all.detect {|u| u["person"]["id"] == id } || inactive_user)
end
generate_cache() click to toggle source
# File lib/yapt/member.rb, line 34
def self.generate_cache
  results = Request.new("memberships").result
  to_cache = { results: results, expires_at: Time.now + Yapt.cache_duration }
  File.open(Yapt.tracker_member_cache, 'w') {|f| f.write to_cache.to_yaml }
  to_cache
end
inactive_user() click to toggle source
# File lib/yapt/member.rb, line 9
def self.inactive_user
  { "person" => { "initials" => '???' } }
end
new(membership) click to toggle source
# File lib/yapt/member.rb, line 14
def initialize(membership)
  @membership = membership
end

Public Instance Methods

initials() click to toggle source
# File lib/yapt/member.rb, line 18
def initials
  membership["person"]["initials"]
end