Sha256: 207e2024b13740c3af7c2de7b1df30864c9d386bc6115f6f5e10531fedd75b97

Contents?: true

Size: 635 Bytes

Versions: 10

Compression:

Stored size: 635 Bytes

Contents

module Rapidfire
  module Questions
    class Numeric < Rapidfire::Question
      def validate_answer(answer)
        super(answer)

        if rules[:presence] == "1" || answer.answer_text.present?
          gt_or_lt = {}
          if rules[:greater_than_or_equal_to].present?
            gt_or_lt[:greater_than_or_equal_to] = rules[:greater_than_or_equal_to].to_i
          end
          if rules[:less_than_or_equal_to].present?
            gt_or_lt[:less_than_or_equal_to] = rules[:less_than_or_equal_to].to_i
          end

          answer.validates_numericality_of :answer_text, gt_or_lt
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
rapidfire-8.0.0 app/models/rapidfire/questions/numeric.rb
rapidfire-5.0.0 app/models/rapidfire/questions/numeric.rb
rapidfire-4.0.0 app/models/rapidfire/questions/numeric.rb
rapidfire-3.1.0 app/models/rapidfire/questions/numeric.rb
rapidfire-3.0.0 app/models/rapidfire/questions/numeric.rb
rapidfire-2.1.0 app/models/rapidfire/questions/numeric.rb
rapidfire-2.0.0 app/models/rapidfire/questions/numeric.rb
unique_rapidfire-1.0.0 app/models/rapidfire/questions/numeric.rb
rapidfire-1.2.0 app/models/rapidfire/questions/numeric.rb
rapidfire-1.0.0 app/models/rapidfire/questions/numeric.rb