Class: Woody::Decorators::ChallengeQuestion

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

Instance Method Summary collapse

Methods inherited from Base

#method_missing

Constructor Details

#initialize(model, answers) ⇒ ChallengeQuestion

Returns a new instance of ChallengeQuestion.



6
7
8
9
# File 'lib/woody/decorators/challenge_question.rb', line 6

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

#answerObject



11
12
13
14
# File 'lib/woody/decorators/challenge_question.rb', line 11

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

#answered?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/woody/decorators/challenge_question.rb', line 16

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

#number_type?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/woody/decorators/challenge_question.rb', line 28

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

#text_type?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/woody/decorators/challenge_question.rb', line 20

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

#textarea_type?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/woody/decorators/challenge_question.rb', line 24

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