Sha256: 8b38b9dc0a21a3eb62f1e181367e9b61d370e8e113fd6f80325ee5b85c91773b
Contents?: true
Size: 884 Bytes
Versions: 1
Compression:
Stored size: 884 Bytes
Contents
module Screengem module Factories # # Knows how to create a Question from a question name. # class QuestionFactory < BasicObject include ::Singleton def method_missing(question_name, *args) question_class_name = "#{question_name}_question".camelize question_class = "#{question_scope}::#{question_class_name}".constantize question_class.new(*args) rescue => e QuestionError.new(<<~MSG) Unable to create question: '#{question_class_name}'. Details: #{e.message} MSG end def respond_to_missing?(_question_name, *) true end class QuestionError < ::Screengem::Question include FactoryCreationError end private def question_scope @question_scope ||= ::Screengem.configuration.question_scope end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
screengem-0.17.0 | lib/screengem/factories/question_factory.rb |