Class: Verso::OccupationData
Overview
Note:
Because an OccupationData object is created for you by other resources you should never need to instantiate one yourself.
Occupation Data
A list of occupations grouped by the Cluster/Pathway that contains them. Occupation Data is not an independent resource. It is a component of OccupationList, Course, and Emphasis.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.find_by_slugs(cslug, pslug, slug) ⇒ Verso::OccupationData?
Find OccupationData by cluster, pathway, and occupation slugs.
Instance Method Summary collapse
-
#cluster ⇒ Verso::Cluster
Cluster (grandparent of occupations).
-
#occupations ⇒ Array
Collection of Occupation objects.
-
#pathway ⇒ Verso::Pathway
Pathway (parent of occupations).
Methods inherited from Base
Constructor Details
This class inherits a constructor from Verso::Base
Class Method Details
.find_by_slugs(cslug, pslug, slug) ⇒ Verso::OccupationData?
Find OccupationData by cluster, pathway, and occupation slugs
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/verso/occupation_data.rb', line 41 def self.find_by_slugs(cslug, pslug, slug) cluster = ClusterList.new.find { |c| c.slug== cslug } pathway = cluster.pathways.find { |p| p.slug == pslug } occupation = pathway.occupations.find { |o| o.slug == slug } OccupationData.new( { :cluster => { :title => cluster.title }, :pathway => { :title => pathway.title }, :occupations => [{ :title => occupation.title }] } ) end |
Instance Method Details
#cluster ⇒ Verso::Cluster
Returns Cluster (grandparent of occupations).
16 17 18 |
# File 'lib/verso/occupation_data.rb', line 16 def cluster @cluster ||= Cluster.new(get_attr(:cluster)) end |
#occupations ⇒ Array
Returns Collection of Verso::Occupation objects.
21 22 23 |
# File 'lib/verso/occupation_data.rb', line 21 def occupations @occupations ||= get_attr(:occupations).collect { |o| Occupation.new(o) } end |
#pathway ⇒ Verso::Pathway
Returns Pathway (parent of occupations).
26 27 28 |
# File 'lib/verso/occupation_data.rb', line 26 def pathway @pathway ||= Pathway.new(get_attr(:pathway)) end |