class OhMyLog::Log::Selector
Selector
is a set of rule that Log.loggable?
will have to respect
Constants
- ACTIONS
- METHODS
Attributes
actions[R]
controllers[R]
ips[R]
methods[R]
status_codes[R]
Public Class Methods
new(controllers: default_hash_setting, actions: default_hash_setting, ips: default_hash_setting, status_codes: default_hash_setting, methods: default_hash_setting)
click to toggle source
TODO: add methods in the same style as anything else and it will affect the parameter method in the loggable function in LOG.rb EXCEPT O ONLY
# File lib/oh_my_log/selector.rb, line 11 def initialize(controllers: default_hash_setting, actions: default_hash_setting, ips: default_hash_setting, status_codes: default_hash_setting, methods: default_hash_setting) @controllers = controllers @actions = actions @ips = ips @status_codes = status_codes @methods = methods build_attr_setters end
Private Class Methods
default_hash_setting()
click to toggle source
# File lib/oh_my_log/selector.rb, line 26 def self.default_hash_setting return {"ALL" => []} end
universal_for(actions: default_hash_setting, controllers: default_hash_setting, methods: default_hash_setting)
click to toggle source
# File lib/oh_my_log/selector.rb, line 40 def self.universal_for(actions: default_hash_setting, controllers: default_hash_setting, methods: default_hash_setting) return Selector.new(controllers: controllers, actions: actions, methods: methods) end
Private Instance Methods
build_attr_setters()
click to toggle source
# File lib/oh_my_log/selector.rb, line 30 def build_attr_setters self.instance_variables.each do |attribute| attribute = attribute.to_s.gsub("@", "") self.define_singleton_method(:"set_#{attribute}") do |value| raise "Unpermitted rule: use #{ACTIONS}" if attribute == "rule" && !ACTIONS.include?(value) instance_variable_set("@#{attribute}", value) end end end
default_hash_setting()
click to toggle source
# File lib/oh_my_log/selector.rb, line 22 def default_hash_setting return {"ALL" => []} end