# frozen_string_literal: true # gem build gvem.gemspec require_relative "gvem/version" ActiveRecord::Base.extend Gvem module Gvem class Error < StandardError; end # Your code goes here... extend ActiveSupport::Concern def hola logger.debug "Hola Govani!" end def show_errors if self.errors.count > 0 logger.debug " =========== error #{self.model_name} ===========" self.errors.each do |attribute, error| logger.debug "#{attribute} => #{error}" end logger.debug " =========== /error ===========" end end def save_json(data = self, title = "", return_json = false) fecha = Time.now fecha = fecha.strftime('%Y/%m/%d') json_path = Rails.application.config.json_path + "#{json_path}/#{self.class.to_s.gsub("::", "_")}/#{fecha}" FileUtils.mkdir_p json_path, :mode => 0777 json_file = "#{json_path}/#{title}_#{self[:id]}.json" #@redis.set(json_file, data.to_json) #logger.debug "=====================================" # logger.debug @redis.get(json_file) # redis.set(json_file, data.to_json ) #logger.debug redis.get(json_file) parameter_file = File.new(json_file, "w") parameter_file.puts(data.to_json) parameter_file.close if return_json return data.to_json else return json_file end end def to_pdf(slug, method_json) doc = Pdf.find_by_slug(slug) file_json = self.public_send(method_json, slug) return "http://localhost:8083/pdf#{doc[:ruta]}?json_file=#{file_json}" end end