Sha256: f399bc5d18b9d5a8b83757db01d0fbbbb58e18680dc66ff082066549ae2f5b83

Contents?: true

Size: 514 Bytes

Versions: 28

Compression:

Stored size: 514 Bytes

Contents

module Surveyor
  module ActsAsResponse
    # Returns the response as a particular response_class type
    def as(type_symbol)
      return case type_symbol.to_sym
      when :string, :text, :integer, :float, :datetime
        self.send("#{type_symbol}_value".to_sym)
      when :date
        self.datetime_value.nil? ? nil : self.datetime_value.to_date
      when :time
        self.datetime_value.nil? ? nil : self.datetime_value.to_time
      else # :answer_id
        self.answer_id
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
affectiva-surveyor-1.5.0.pre.disco.2 lib/surveyor/acts_as_response.rb
hssc_surveyor-1.4.3.pre lib/surveyor/acts_as_response.rb
hssc_surveyor-1.4.2.pre lib/surveyor/acts_as_response.rb
hssc_surveyor-1.4.1.pre lib/surveyor/acts_as_response.rb
surveyor-1.4.0 lib/surveyor/acts_as_response.rb
surveyor-1.3.0 lib/surveyor/acts_as_response.rb
surveyor-1.2.0 lib/surveyor/acts_as_response.rb
surveyor-1.1.0 lib/surveyor/acts_as_response.rb
surveyor-1.0.1 lib/surveyor/acts_as_response.rb
surveyor-1.0.0 lib/surveyor/acts_as_response.rb
surveyor-0.22.0 lib/surveyor/acts_as_response.rb
surveyor-0.21.0 lib/surveyor/acts_as_response.rb
surveyor-0.20.0 lib/surveyor/acts_as_response.rb
surveyor-0.19.7 lib/surveyor/acts_as_response.rb
surveyor-0.19.6 lib/surveyor/acts_as_response.rb
surveyor-0.19.5 lib/surveyor/acts_as_response.rb
surveyor-0.19.4 lib/surveyor/acts_as_response.rb
surveyor-0.19.3 lib/surveyor/acts_as_response.rb
surveyor-0.19.2 lib/surveyor/acts_as_response.rb
surveyor-0.19.1 lib/surveyor/acts_as_response.rb