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) ⇒ Question
Run the defined postprocessors on the given question.
-
#question(name, text, attrs = {}, &instance_block) ⇒ Question
Give a new question.
-
#when_questioned(&postprocessor) ⇒ Object
Give instructions for dealing with new questions.
Instance Method Details
#postprocess_question(question) ⇒ Question
Run the defined postprocessors on the given question.
Useful when you need to postprocess questions at a higher level.
22 23 24 25 26 27 28 29 |
# File 'lib/interrogative.rb', line 22 def postprocess_question(question) unless @_question_postprocessors.nil? @_question_postprocessors.each do |postprocessor| postprocessor.call(question) end end question end |
#question(name, text, attrs = {}, &instance_block) ⇒ Question
Give a new question.
44 45 46 47 48 49 50 |
# File 'lib/interrogative.rb', line 44 def question(name, text, attrs={}, &instance_block) q = Question.new(name, text, self, attrs, &instance_block) (@_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 unless postprocessor.nil? end |