Class: ConceptView
- Inherits:
-
Object
- Object
- ConceptView
- Defined in:
- app/view_models/concept_view.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#alt_labels ⇒ Object
readonly
Returns the value of attribute alt_labels.
-
#languages ⇒ Object
readonly
Returns the value of attribute languages.
-
#pref_labels ⇒ Object
readonly
Returns the value of attribute pref_labels.
Instance Method Summary collapse
-
#collections ⇒ Object
returns a list of ‘Link`s.
-
#definition ⇒ Object
returns a string.
-
#initialize(concept, h) ⇒ ConceptView
constructor
‘h` is the controller/helper context which acts as a proxy here.
- #no_content? ⇒ Boolean
-
#related ⇒ Object
related concepts returns a list of ‘Link`s.
Constructor Details
#initialize(concept, h) ⇒ ConceptView
‘h` is the controller/helper context which acts as a proxy here
26 27 28 29 30 |
# File 'app/view_models/concept_view.rb', line 26 def initialize(concept, h) @h = h @concept = concept @published = @concept.published? ? nil : '0' end |
Instance Attribute Details
#alt_labels ⇒ Object (readonly)
Returns the value of attribute alt_labels.
3 4 5 |
# File 'app/view_models/concept_view.rb', line 3 def alt_labels @alt_labels end |
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
2 3 4 |
# File 'app/view_models/concept_view.rb', line 2 def languages @languages end |
#pref_labels ⇒ Object (readonly)
Returns the value of attribute pref_labels.
3 4 5 |
# File 'app/view_models/concept_view.rb', line 3 def pref_labels @pref_labels end |
Instance Method Details
#collections ⇒ Object
returns a list of ‘Link`s
59 60 61 62 63 |
# File 'app/view_models/concept_view.rb', line 59 def collections @collections ||= @concept.collections.map do |coll| Link.new(coll.label.to_s, h.collection_path(:id => coll)) end end |
#definition ⇒ Object
returns a string
37 38 39 40 41 |
# File 'app/view_models/concept_view.rb', line 37 def definition @definition ||= @concept.notes_for_class(Note::SKOS::Definition) .first # FIXME: hard-coded class, arbitrary pick .try(:value) end |
#no_content? ⇒ Boolean
32 33 34 |
# File 'app/view_models/concept_view.rb', line 32 def no_content? definition.blank? && alt_labels.none? && .none? && collections.none? end |
#related ⇒ Object
related concepts returns a list of ‘Link`s
49 50 51 52 53 54 55 56 |
# File 'app/view_models/concept_view.rb', line 49 def klass = Iqvoc::Concept.further_relation_classes.first # XXX: arbitrary; bad heuristic? @related = @concept.(klass, @published). map do |rel_concept| Link.new(rel_concept.pref_label.to_s, h.concept_path(:id => rel_concept)) end end |