Sha256: 078c57347b1fdfe0b89237cd0978ed0916a842d1bf880ef1591a389f90515ad6
Contents?: true
Size: 848 Bytes
Versions: 24
Compression:
Stored size: 848 Bytes
Contents
require 'active_record' module Surveyor module Response def self.included(base) base.extend(ClassMethods) end module ClassMethods def acts_as_response include Surveyor::Response::InstanceMethods end end module InstanceMethods # 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 end ActiveRecord::Base.send(:include, Surveyor::Response)
Version data entries
24 entries across 24 versions & 3 rubygems