class SQLtorial::QueryCache
Attributes
query_to_md[R]
Public Class Methods
new(query_to_md)
click to toggle source
# File lib/sqltorial/query_cache.rb, line 7 def initialize(query_to_md) @query_to_md = query_to_md end
Public Instance Methods
cache_file()
click to toggle source
# File lib/sqltorial/query_cache.rb, line 23 def cache_file @cache_file ||= Pathname.pwd + '.sqltorial_cache' + cache_file_name end
cache_file_name()
click to toggle source
# File lib/sqltorial/query_cache.rb, line 27 def cache_file_name @cache_file_name ||= Digest::SHA256.hexdigest("#{input_str}") + ".md" end
input_str()
click to toggle source
# File lib/sqltorial/query_cache.rb, line 31 def input_str @input_str ||= %w(query row_limit validation_directives other_directives).inject("") do |s, meth| s + query_to_md.send(meth).inspect end end
make_cache_file()
click to toggle source
# File lib/sqltorial/query_cache.rb, line 18 def make_cache_file cache_file.dirname.mkpath cache_file.write(query_to_md.get_md) end
to_md()
click to toggle source
# File lib/sqltorial/query_cache.rb, line 11 def to_md unless cache_file.exist? make_cache_file end cache_file.read end