class ProactiveSupport::Mgmt::Flags
Public Class Methods
clear(customer_id, source, identifier, filter)
click to toggle source
# File lib/proactive_support/mgmt/flags.rb, line 23 def clear(customer_id, source, identifier, filter) clear_matching customer_id, {digest: to_digest(source, identifier, filter)} end
clear_identifier(customer_id, source, identifier)
click to toggle source
# File lib/proactive_support/mgmt/flags.rb, line 27 def clear_identifier(customer_id, source, identifier) clear_matching customer_id, {source: source, identifier: identifier} end
clear_source(customer_id, source)
click to toggle source
# File lib/proactive_support/mgmt/flags.rb, line 31 def clear_source(customer_id, source) clear_matching customer_id, {source: source} end
set(customer_id, source, identifier, filter, message, options = {})
click to toggle source
# File lib/proactive_support/mgmt/flags.rb, line 5 def set(customer_id, source, identifier, filter, message, options = {}) digest = to_digest source, identifier, filter ::ProactiveSupport::Flag.where(customer_id: customer_id, digest: digest).first_or_initialize.tap do |f| f.source = source f.identifier = identifier f.filter = clean_object filter f.message = message.to_str[0,255] # truncate to size of db column f.level = options[:level] || ::ProactiveSupport::INFO f.debug_params = clean_object options[:debug_params] f.tags = options[:tags] f.is_transient = options.fetch(:transient, true) ? true : false f.last_triggered_at = ::Time.now f.is_active = true f.save! end end
Private Class Methods
clean_object(data)
click to toggle source
# File lib/proactive_support/mgmt/flags.rb, line 46 def clean_object(data) if RUBY_PLATFORM == 'java' # This attempts to strip out any Java objects so we serialize with compatible MRI Ruby classes data = ::JSON.load(::JSON.dump(data)) end ::HashWithIndifferentAccess.new data end
clear_matching(customer_id, conditions)
click to toggle source
# File lib/proactive_support/mgmt/flags.rb, line 42 def clear_matching(customer_id, conditions) ::ProactiveSupport::Flag.where(customer_id: customer_id, is_active: true).update_all({is_active: false}, conditions) end
to_digest(source, identifier, filter)
click to toggle source
# File lib/proactive_support/mgmt/flags.rb, line 37 def to_digest(source, identifier, filter) x = "#{source}:#{identifier}:#{filter}" ::Digest::SHA1.base64digest x end