Class: Everypolitician::Popolo::Membership

Inherits:
Entity
  • Object
show all
Defined in:
lib/everypolitician/popolo/membership.rb

Instance Attribute Summary

Attributes inherited from Entity

#document, #popolo

Instance Method Summary collapse

Methods inherited from Entity

#[], classification, #id, #identifier, #identifiers, inherited, #initialize, #key?, subclasses, #wikidata

Constructor Details

This class inherits a constructor from Everypolitician::Popolo::Entity

Instance Method Details

#==(other) ⇒ Object Also known as: eql?


77
78
79
# File 'lib/everypolitician/popolo/membership.rb', line 77

def ==(other)
  self.class == other.class && instance_variables.all? { |v| instance_variable_get(v) == other.instance_variable_get(v) }
end

#areaObject


69
70
71
# File 'lib/everypolitician/popolo/membership.rb', line 69

def area
  popolo.areas.find_by(id: area_id)
end

#area_idObject


21
22
23
# File 'lib/everypolitician/popolo/membership.rb', line 21

def area_id
  document.fetch(:area_id, nil)
end

#end_dateObject


41
42
43
# File 'lib/everypolitician/popolo/membership.rb', line 41

def end_date
  document.fetch(:end_date, nil)
end

#legislative_periodObject Also known as: term


57
58
59
# File 'lib/everypolitician/popolo/membership.rb', line 57

def legislative_period
  popolo.events.find_by(id: legislative_period_id)
end

#legislative_period_idObject


25
26
27
# File 'lib/everypolitician/popolo/membership.rb', line 25

def legislative_period_id
  document.fetch(:legislative_period_id, nil)
end

#on_behalf_ofObject Also known as: party


63
64
65
# File 'lib/everypolitician/popolo/membership.rb', line 63

def on_behalf_of
  popolo.organizations.find_by(id: on_behalf_of_id)
end

#on_behalf_of_idObject


13
14
15
# File 'lib/everypolitician/popolo/membership.rb', line 13

def on_behalf_of_id
  document.fetch(:on_behalf_of_id, nil)
end

#organizationObject


53
54
55
# File 'lib/everypolitician/popolo/membership.rb', line 53

def organization
  popolo.organizations.find_by(id: organization_id)
end

#organization_idObject


17
18
19
# File 'lib/everypolitician/popolo/membership.rb', line 17

def organization_id
  document.fetch(:organization_id, nil)
end

#personObject


49
50
51
# File 'lib/everypolitician/popolo/membership.rb', line 49

def person
  popolo.persons.find_by(id: person_id)
end

#person_idObject


9
10
11
# File 'lib/everypolitician/popolo/membership.rb', line 9

def person_id
  document.fetch(:person_id, nil)
end

#postObject


73
74
75
# File 'lib/everypolitician/popolo/membership.rb', line 73

def post
  popolo.posts.find_by(id: post_id)
end

#post_idObject


29
30
31
# File 'lib/everypolitician/popolo/membership.rb', line 29

def post_id
  document.fetch(:post_id, nil)
end

#roleObject


33
34
35
# File 'lib/everypolitician/popolo/membership.rb', line 33

def role
  document.fetch(:role, nil)
end

#sourcesObject


45
46
47
# File 'lib/everypolitician/popolo/membership.rb', line 45

def sources
  document.fetch(:sources, [])
end

#start_dateObject


37
38
39
# File 'lib/everypolitician/popolo/membership.rb', line 37

def start_date
  document.fetch(:start_date, nil)
end