Class: Woody::Decorators::BriefQuestion

Inherits:
Base
  • Object
show all
Defined in:
lib/woody/decorators/brief_question.rb

Instance Method Summary collapse

Methods inherited from Base

#method_missing

Constructor Details

#initialize(model, answers) ⇒ BriefQuestion

Returns a new instance of BriefQuestion.



7
8
9
10
# File 'lib/woody/decorators/brief_question.rb', line 7

def initialize(model, answers)
  @answers = answers
  super(model)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Woody::Decorators::Base

Instance Method Details

#answer(link_wrap = false) ⇒ Object



12
13
14
15
16
# File 'lib/woody/decorators/brief_question.rb', line 12

def answer(link_wrap = false)
  answer_item = answer_for_question(@model.id)
  answer = answer_item ? answer_item.answer : ''
  link_wrap ? link_wrap_answer(answer) : answer
end

#answered?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/woody/decorators/brief_question.rb', line 18

def answered?
  answer_for_question(@model.id).nil? ? false : true
end

#number_type?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/woody/decorators/brief_question.rb', line 30

def number_type?
  @model.type == 'number'
end

#text_type?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/woody/decorators/brief_question.rb', line 22

def text_type?
  @model.type == 'text'
end

#textarea_type?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/woody/decorators/brief_question.rb', line 26

def textarea_type?
  @model.type == 'textarea'
end