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.

Since:

  • 0.1.0

Instance Method Summary collapse

Methods included from Helpers::DateHelper

#date_range

Instance Method Details

#answering_body_allocationGrom::Node?

Alias questionHasAnsweringBodyAllocation with fallback.

Returns:

  • (Grom::Node, nil)

    the answering_body_allocation of the Grom::Node or nil.

Since:

  • 0.1.0



45
46
47
# File 'lib/parliament/grom/decorator/question.rb', line 45

def answering_body_allocation
  respond_to?(:questionHasAnsweringBodyAllocation) ? questionHasAnsweringBodyAllocation.first : nil
end

#answersArray

Alias questionHasAnswer with fallback.

Returns:

  • (Array, Array)

    the answers related to the Grom::Node or an empty array.

Since:

  • 0.1.0



38
39
40
# File 'lib/parliament/grom/decorator/question.rb', line 38

def answers
  respond_to?(:questionHasAnswer) ? questionHasAnswer : []
end

#asked_at_dateDateTime?

Alias questionAskedAt with fallback.

Returns:

  • (DateTime, nil)

    the asked_at_date of the Grom::Node or nil.

Since:

  • 0.1.0



24
25
26
# File 'lib/parliament/grom/decorator/question.rb', line 24

def asked_at_date
  @asked_at_date ||= respond_to?(:questionAskedAt) ? DateTime.parse(questionAskedAt) : nil
end

#asking_personGrom::Node?

Alias questionHasAskingPerson with fallback.

Returns:

  • (Grom::Node, nil)

    the asking_person of the Grom::Node or nil.

Since:

  • 0.1.0



31
32
33
# File 'lib/parliament/grom/decorator/question.rb', line 31

def asking_person
  respond_to?(:questionHasAskingPerson) ? questionHasAskingPerson.first : nil
end

#textString

Alias questionText with fallback.

Returns:

  • (String, String)

    the text of the Grom::Node or an empty string.

Since:

  • 0.1.0



10
11
12
# File 'lib/parliament/grom/decorator/question.rb', line 10

def text
  respond_to?(:questionText) ? questionText : ''
end

#uinString

Alias eqmUin with fallback.

Returns:

  • (String, String)

    the uin of the Grom::Node or an empty string.

Since:

  • 0.1.0



17
18
19
# File 'lib/parliament/grom/decorator/question.rb', line 17

def uin
  respond_to?(:eqmUin) ? eqmUin : ''
end