class RTALogger::LogFilterBase

Attributes

action[RW]

possible values: accept, ignore

default_regex[RW]
enable[RW]
title[RW]

Public Class Methods

new() click to toggle source
# File lib/log_filter_base.rb, line 3
def initialize
  @title = self.class.to_s.split('::').last.underscore
  @enable = true
  @action = :accept
end

Public Instance Methods

apply_run_time_config(config_json) click to toggle source
# File lib/log_filter_base.rb, line 27
def apply_run_time_config(config_json)
  @enable = config_json['enable'].nil? ? true : config_json['enable'].present?
  @default_regex = config_json['default_regex'] if config_json['default_regex'].present?
  @action = valid_action(config_json['action']) if config_json['action'].present?
end
load_config(config_json) click to toggle source
# File lib/log_filter_base.rb, line 20
def load_config(config_json)
  @title = config_json['title'] if config_json['title'].present?
  @enable = config_json['enable'].nil? ? true : config_json['enable'].present?
  @default_regex = config_json['default_regex'] if config_json['default_regex'].present?
  @action = valid_action(config_json['action']) if config_json['action'].present?
end
match_conditions(log_record) click to toggle source
# File lib/log_filter_base.rb, line 15
def match_conditions(log_record)
  return true if !@enable
  return log_record.present?
end
to_builder() click to toggle source
# File lib/log_filter_base.rb, line 33
def to_builder
  jb = Jbuilder.new do |json|
    json.type self.class.to_s.split('::').last.underscore.sub('log_filter_', '')
    json.title @title
    json.enable @enable
    json.default_regex @default_regex
    json.action @action.to_s
  end

  jb
end

Private Instance Methods

valid_action(action_value) click to toggle source
# File lib/log_filter_base.rb, line 47
def valid_action(action_value)
  case action_value.to_s.downcase
  when 'accept'
    :accept
  when 'ignore'
    :ignore
  else
    :accept
  end
end