Sha256: 5d52a06a4241ad0c0421b70c1aa13fc8508a8355d9caa2ada09ec85b4f6ae682
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
# 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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gvem-0.1.1 | lib/gvem.rb |
gvem-0.1.0 | lib/gvem.rb |