class TritonOps::Snapshot
Attributes
headnode[R]
timestamp[R]
Public Class Methods
new(headnode, timestamp, **options)
click to toggle source
# File lib/triton-ops/snapshot.rb, line 17 def initialize(headnode, timestamp, **options) @headnode = headnode @timestamp = Coerce.to_time timestamp @namespace = options.fetch(:namespace) { '' } self end
Public Instance Methods
array_from_json_at_redis_prefix()
click to toggle source
# File lib/triton-ops/snapshot.rb, line 30 def array_from_json_at_redis_prefix raise TypeError unless type = ::TritonOps::Resource.constants.find { |name| name.to_s.downcase == __callee__.to_s.chop } if instance_variable_defined? "@#{__callee__}" instance_variable_get "@#{__callee__}" else instance_variable_set( "@#{__callee__}", JSON.parse( (redis.get("#{prefix}/#{__callee__}") || '[]'), symbolize_names: true).map { |spec| ::TritonOps::Resource.const_get(type).new spec }) end end
prefix()
click to toggle source
# File lib/triton-ops/snapshot.rb, line 26 def prefix @prefix ||= "#{@namespace}/headnode/#{headnode}/snapshot/#{timestamp.iso8601}" end
Private Instance Methods
redis()
click to toggle source
# File lib/triton-ops/snapshot.rb, line 52 def redis @redis ||= Redis.new end