Class: TrogdirChange

Inherits:
Object
  • Object
show all
Defined in:
lib/trogdir_change.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ TrogdirChange

Returns a new instance of TrogdirChange.


3
4
5
# File 'lib/trogdir_change.rb', line 3

def initialize(hash)
  @hash = hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash


2
3
4
# File 'lib/trogdir_change.rb', line 2

def hash
  @hash
end

Instance Method Details

#account_info_updated?Boolean

Returns:

  • (Boolean)

83
84
85
# File 'lib/trogdir_change.rb', line 83

def 
  person? && (create? || update?) && (name_changed? || work_changed? || privacy_changed?)
end

#affiliation_added?Boolean

Returns:

  • (Boolean)

75
76
77
# File 'lib/trogdir_change.rb', line 75

def affiliation_added?
  person? && (create? || update?) && affiliations_changed?
end

#affiliationsObject


43
44
45
46
47
48
49
# File 'lib/trogdir_change.rb', line 43

def affiliations
  if modified.has_key? 'affiliations'
    modified['affiliations']
  else
    all_attrs['affiliations']
  end
end

#biola_idObject


15
16
17
# File 'lib/trogdir_change.rb', line 15

def biola_id
  Array(all_attrs['ids']).find { |id| id['type'] == 'biola_id' }['identifier']
end

#departmentObject


39
40
41
# File 'lib/trogdir_change.rb', line 39

def department
  all_attrs['department']
end

#first_nameObject


23
24
25
# File 'lib/trogdir_change.rb', line 23

def first_name
  all_attrs['first_name']
end

#joined_groupsObject


91
92
93
94
# File 'lib/trogdir_change.rb', line 91

def joined_groups
  return [] unless person?
  Array(modified['groups']) - Array(original['groups'])
end

#last_nameObject


31
32
33
# File 'lib/trogdir_change.rb', line 31

def last_name
  all_attrs['last_name']
end

#left_groupsObject


96
97
98
99
# File 'lib/trogdir_change.rb', line 96

def left_groups
  return [] unless person?
  Array(original['groups']) - Array(modified['groups'])
end

#middle_nameObject


27
28
29
# File 'lib/trogdir_change.rb', line 27

def middle_name
  all_attrs['middle_name']
end

#new_university_emailObject


63
64
65
# File 'lib/trogdir_change.rb', line 63

def new_university_email
  modified['address']
end

#old_university_emailObject


67
68
69
# File 'lib/trogdir_change.rb', line 67

def old_university_email
  original['address']
end

#person_uuidObject


11
12
13
# File 'lib/trogdir_change.rb', line 11

def person_uuid
  hash['person_id']
end

#preferred_nameObject


19
20
21
# File 'lib/trogdir_change.rb', line 19

def preferred_name
  all_attrs['preferred_name']
end

#privacyObject


51
52
53
# File 'lib/trogdir_change.rb', line 51

def privacy
  all_attrs['privacy']
end

#sync_log_idObject


7
8
9
# File 'lib/trogdir_change.rb', line 7

def sync_log_id
  hash['sync_log_id']
end

#titleObject


35
36
37
# File 'lib/trogdir_change.rb', line 35

def title
  all_attrs['title']
end

#university_emailObject


55
56
57
58
59
60
61
# File 'lib/trogdir_change.rb', line 55

def university_email
  if person?
    Array(all_attrs['emails']).find { |email| email['type'] == 'university' }['address']
  elsif email?
    all_attrs['address']
  end
end

#university_email_added?Boolean

Returns:

  • (Boolean)

79
80
81
# File 'lib/trogdir_change.rb', line 79

def university_email_added?
  email? && create? && all_attrs['type'] == 'university'
end

#university_email_exists?Boolean

Returns:

  • (Boolean)

71
72
73
# File 'lib/trogdir_change.rb', line 71

def university_email_exists?
  Array(all_attrs['emails']).any? { |email| email['type'] == 'university' }
end

#university_email_updated?Boolean

Returns:

  • (Boolean)

87
88
89
# File 'lib/trogdir_change.rb', line 87

def university_email_updated?
  email? && update? && all_attrs['type'] == 'university'
end