Class: Everypolitician::Popolo::Events

Inherits:
Collection
  • Object
show all
Defined in:
lib/everypolitician/popolo/event.rb

Instance Attribute Summary

Attributes inherited from Collection

#documents, #popolo

Instance Method Summary collapse

Methods inherited from Collection

#-, #each, #empty?, entity_class, #find_by, #initialize, #of_collection, #where

Constructor Details

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

Instance Method Details

#class_for_entity(document) ⇒ Object


41
42
43
44
45
# File 'lib/everypolitician/popolo/event.rb', line 41

def class_for_entity(document)
  @entity_class[document[:classification]] ||= self.class.entity_class.subclasses.find do |e|
    e.classification == document[:classification]
  end || self.class.entity_class
end

#electionsObject


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

def elections
  of_collection(Elections)
end

#legislative_periodsObject


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

def legislative_periods
  of_collection(LegislativePeriods)
end