class MerrittZK::IngestState
Class details
Attributes
next_status[R]
status[R]
Public Class Methods
new(status, next_status)
click to toggle source
# File lib/merritt_zk_state.rb, line 11 def initialize(status, next_status) next_status = {} if next_status.nil? @status = status @next_status = next_status.keys @success_state = nil @fail_state = nil next_status.each do |k, v| next if v.nil? @success_state = k if v.fetch(:success, false) @fail_state = k if v.fetch(:fail, false) end end
state_yaml()
click to toggle source
# File lib/merritt_zk_state.rb, line 25 def self.state_yaml JSON.parse( YAML.safe_load_file(File.join(File.dirname(__FILE__), '../../../../states.yml'), aliases: true).to_json, symbolize_names: true ) end
Public Instance Methods
deletable?()
click to toggle source
# File lib/merritt_zk_state.rb, line 38 def deletable? @next_status.empty? end
fail_lookup(states)
click to toggle source
# File lib/merritt_zk_state.rb, line 46 def fail_lookup(states) states.fetch(fail_state, nil) end
name()
click to toggle source
# File lib/merritt_zk_state.rb, line 34 def name @status.to_s end
state_change_allowed(state)
click to toggle source
# File lib/merritt_zk_state.rb, line 50 def state_change_allowed(state) next_status.include?(state) end
state_lookup(states, state)
click to toggle source
# File lib/merritt_zk_state.rb, line 54 def state_lookup(states, state) states.fetch(state, nil) if state_change_allowed(state) end
success_lookup(states)
click to toggle source
# File lib/merritt_zk_state.rb, line 42 def success_lookup(states) states.fetch(success_state, nil) end
to_s()
click to toggle source
# File lib/merritt_zk_state.rb, line 58 def to_s "#{@status}: #{@next_status}" end