Module: Parliament::Grom::Decorator::Question
- Includes:
- Helpers::DateHelper
- Defined in:
- lib/parliament/grom/decorator/question.rb
Overview
Decorator namespace for Grom::Node instances with type: id.parliament.uk/schema/Question.
Instance Method Summary collapse
-
#answering_body_allocation ⇒ Grom::Node?
Alias questionHasAnsweringBodyAllocation with fallback.
-
#answers ⇒ Array
Alias questionHasAnswer with fallback.
-
#asked_at_date ⇒ DateTime?
Alias questionAskedAt with fallback.
-
#asking_person ⇒ Grom::Node?
Alias questionHasAskingPerson with fallback.
-
#fallback_heading ⇒ String
Builds a fallback question heading using indexingAndSearchUri.
-
#heading ⇒ String
Returns heading or fallback_heading.
-
#indexing_search_uri ⇒ String
Alias indexingAndSearchUri with fallback.
-
#question_title ⇒ String
Alias questionHeading with fallback.
-
#text ⇒ String
Alias questionText with fallback.
Methods included from Helpers::DateHelper
Instance Method Details
#answering_body_allocation ⇒ Grom::Node?
Alias questionHasAnsweringBodyAllocation with fallback.
66 67 68 |
# File 'lib/parliament/grom/decorator/question.rb', line 66 def answering_body_allocation respond_to?(:questionHasAnsweringBodyAllocation) ? questionHasAnsweringBodyAllocation.first : nil end |
#answers ⇒ Array
Alias questionHasAnswer with fallback.
59 60 61 |
# File 'lib/parliament/grom/decorator/question.rb', line 59 def answers respond_to?(:questionHasAnswer) ? questionHasAnswer : [] end |
#asked_at_date ⇒ DateTime?
Alias questionAskedAt with fallback.
45 46 47 |
# File 'lib/parliament/grom/decorator/question.rb', line 45 def asked_at_date @asked_at_date ||= respond_to?(:questionAskedAt) ? DateTime.parse(questionAskedAt) : nil end |
#asking_person ⇒ Grom::Node?
Alias questionHasAskingPerson with fallback.
52 53 54 |
# File 'lib/parliament/grom/decorator/question.rb', line 52 def asking_person respond_to?(:questionHasAskingPerson) ? questionHasAskingPerson.first : nil end |
#fallback_heading ⇒ String
Builds a fallback question heading using indexingAndSearchUri.
17 18 19 |
# File 'lib/parliament/grom/decorator/question.rb', line 17 def fallback_heading "Question #{indexing_search_uri.split('/').last}" end |
#heading ⇒ String
Returns heading or fallback_heading.
24 25 26 |
# File 'lib/parliament/grom/decorator/question.rb', line 24 def heading question_title.empty? || question_title.include?('Tabled Parliamentary Question') ? fallback_heading : question_title end |
#indexing_search_uri ⇒ String
Alias indexingAndSearchUri with fallback.
38 39 40 |
# File 'lib/parliament/grom/decorator/question.rb', line 38 def indexing_search_uri respond_to?(:indexingAndSearchUri) ? indexingAndSearchUri : '' end |
#question_title ⇒ String
Alias questionHeading with fallback.
10 11 12 |
# File 'lib/parliament/grom/decorator/question.rb', line 10 def question_title respond_to?(:questionHeading) ? questionHeading : '' end |
#text ⇒ String
Alias questionText with fallback.
31 32 33 |
# File 'lib/parliament/grom/decorator/question.rb', line 31 def text respond_to?(:questionText) ? questionText : '' end |