Module: Interrogative::BaseMethods
- Included in:
- ClassMethods, InstanceMethods
- Defined in:
- lib/interrogative.rb
Overview
Methods applicable on both the class and instance levels.
Instance Method Summary collapse
-
#postprocess_question(question) ⇒ Object
Run the defined postprocessors on the given question.
-
#question(name, text, attrs = {}) ⇒ Question
Give a new question.
-
#when_questioned(&postprocessor) ⇒ Object
Give instructions for dealing with new questions.
Instance Method Details
#postprocess_question(question) ⇒ Object
Run the defined postprocessors on the given question.
Useful when you need to postprocess questions at a higher level.
21 22 23 24 25 26 27 |
# File 'lib/interrogative.rb', line 21 def postprocess_question(question) unless @_question_postprocessors.nil? @_question_postprocessors.each do |postprocessor| postprocessor.call(question) end end end |
#question(name, text, attrs = {}) ⇒ Question
Give a new question.
40 41 42 43 44 45 46 47 |
# File 'lib/interrogative.rb', line 40 def question(name, text, attrs={}) q = Question.new(name, text, self, attrs) (@_questions||=[]) << q postprocess_question(q) return q end |
#when_questioned(&postprocessor) ⇒ Object
Give instructions for dealing with new questions.
12 13 14 |
# File 'lib/interrogative.rb', line 12 def when_questioned(&postprocessor) (@_question_postprocessors||=[]) << postprocessor end |