lib/snip_snap_zap/delayed_jobs/snip_snap_job.rb
# Convert an object returned by an association into a hash
Convert an object returned by an association into a hash
Convert an object returned by an association into a hash
def assoc_to_h(obj)
        Rails.logger.debug "OBJ: #{obj}"
        Rails.logger.debug "ATTRIBUTES?: #{obj.respond_to?(:attributes)}"
        Rails.logger.debug "MAP?: #{respond_to?(:map)}"
        if obj.respond_to? :attributes
          obj.attributes
        elsif obj.respond_to?(:map)
          obj.map do |el|
            assoc_to_h(el)
          end
        else
          obj
        end
      end
def assoc_to_h ( obj ) Rails . logger . debug "OBJ: #{obj}" Rails . logger . debug "ATTRIBUTES?: #{obj.respond_to?(:attributes)}" Rails . logger . debug "MAP?: #{respond_to?(:map)}" if obj . respond_to? :attributes obj . attributes elsif obj . respond_to? ( :map ) obj . map do | el | assoc_to_h ( el ) end else obj end end
Convert an object returned by an association into a hash
Convert an object returned by an association into a hash
obj