class Rpx::Resident

Public Class Methods

current_residents(options, client=Client.new(options)) click to toggle source
# File lib/rpx/resident.rb, line 76
def self.current_residents(options, client=Client.new(options))
  self.where(options, client).select{|resident| resident.current_resident? }
end
where(options, client=Client.new(options)) click to toggle source
# File lib/rpx/resident.rb, line 43
def self.where(options, client=Client.new(options))
  resident_hashs = client.api_call :getresidentlist, options do |xml|
    xml.tem :residentsearch do |xml|
      xml.tem :extensionData
      client.add_attributes_if_present(xml, options, Resident.properties.to_a)
    end
  end

  site_properties = {siteid: options.fetch(:siteid), pmcid: options.fetch(:pmcid)}
  [resident_hashs].flatten.map{ |resident_hash| Resident.new(resident_hash.merge(site_properties)) }
end

Public Instance Methods

current_lease() click to toggle source
# File lib/rpx/resident.rb, line 59
def current_lease
  @current_lease ||= leases.sort_by{ |lease| lease.dateend }.last
end
current_resident?() click to toggle source
# File lib/rpx/resident.rb, line 80
def current_resident?
  self.leasestatus == "Current"
end
fullname() click to toggle source
# File lib/rpx/resident.rb, line 84
def fullname
  "#{firstname} #{lastname}".strip #TODO: ask them to add middleman saluration and generation in the api
end
leases() click to toggle source
# File lib/rpx/resident.rb, line 55
def leases
  @leases ||= ResidentWithLease.find({resident_id: self.resident_id, siteid: siteid, pmcid: pmcid}).leases
end
minor?() click to toggle source
# File lib/rpx/resident.rb, line 73
def minor?
  current_lease.residentrelationship.downcase[/minor/]
end
moved_out?() click to toggle source
# File lib/rpx/resident.rb, line 67
def moved_out?
  return false if current_resident?

  current_lease.moved_out?
end
residenttype() click to toggle source
# File lib/rpx/resident.rb, line 39
def residenttype
  self[:residenttype] == 'H' ? 'Head of Household' : 'Other'
end
status() click to toggle source
# File lib/rpx/resident.rb, line 63
def status
  current_lease.leasestatus
end