Class: Tracing::BaseAppender
- Includes:
- FilterUse
- Defined in:
- lib/appenders/base_appender.rb
Overview
base appender (abstract)
Direct Known Subclasses
Class Attribute Summary collapse
-
.templates ⇒ Object
Returns the value of attribute templates.
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Attributes included from FilterUse
Attributes included from Filter::ExecUse
Attributes included from Filter::Registration
Class Method Summary collapse
Instance Method Summary collapse
- #allow_append(txt, context) ⇒ Object
-
#handle(txt, context) ⇒ Object
default action handler depending on filters result.
-
#initialize(init_options = nil) ⇒ BaseAppender
constructor
A new instance of BaseAppender.
- #not_allow_append(txt, context) ⇒ Object
- #time_limit ⇒ Object
Methods included from Filter::Registration
#_register_filters, #create_filters, #register_filters, #unregister_filters
Constructor Details
#initialize(init_options = nil) ⇒ BaseAppender
Returns a new instance of BaseAppender.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/appenders/base_appender.rb', line 31 def initialize( = nil) return if ! if .kind_of? Hash = [:options] || register_filters([:filters]) template = [:template] if return if !template @template = self.class.create_template(template) elsif .kind_of? Symbol self.class.register_templates tracer = self.class.templates[] return if !tracer @template = self.class.create_template(template) else raise Exception, "Appender must be initialized with Hash" end end |
Class Attribute Details
.templates ⇒ Object
Returns the value of attribute templates.
10 11 12 |
# File 'lib/appenders/base_appender.rb', line 10 def templates @templates end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/appenders/base_appender.rb', line 6 def end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
7 8 9 |
# File 'lib/appenders/base_appender.rb', line 7 def templates @templates end |
Class Method Details
.create_template(template) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/appenders/base_appender.rb', line 18 def create_template(template) templates ||= register_templates if template.kind_of?(Symbol) || template.kind_of?(String) template_class = templates[template.to_sym] || templates[:default] template_class.new elsif template.kind_of? Tracing::BaseTemplate template else nil end end |
.register_templates(templates = nil) ⇒ Object
13 14 15 16 |
# File 'lib/appenders/base_appender.rb', line 13 def register_templates(templates = nil) @templates ||= {} # default_templates @templates = @templates.merge!(templates || {}) end |
Instance Method Details
#allow_append(txt, context) ⇒ Object
60 61 62 |
# File 'lib/appenders/base_appender.rb', line 60 def allow_append(txt, context) end |
#handle(txt, context) ⇒ Object
default action handler depending on filters result
52 53 54 55 56 57 58 |
# File 'lib/appenders/base_appender.rb', line 52 def handle(txt, context) if filters_allow?(txt, context) allow_append(txt, context) else not_allow_append(txt, context) end end |
#not_allow_append(txt, context) ⇒ Object
64 65 |
# File 'lib/appenders/base_appender.rb', line 64 def not_allow_append(txt, context) end |
#time_limit ⇒ Object
67 68 69 |
# File 'lib/appenders/base_appender.rb', line 67 def time_limit [:time_limit] || 1.minute end |