Class: Timber::Contexts::Custom
- Inherits:
-
Timber::Context
- Object
- Timber::Context
- Timber::Contexts::Custom
- Defined in:
- lib/timber/contexts/custom.rb
Overview
Custom contexts allow you to add application specific context not covered elsewhere.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
-
#initialize(attributes) ⇒ Custom
constructor
A new instance of Custom.
Constructor Details
#initialize(attributes) ⇒ Custom
Returns a new instance of Custom.
15 16 17 18 |
# File 'lib/timber/contexts/custom.rb', line 15 def initialize(attributes) @type = attributes[:type] || raise(ArgumentError.new(":type is required")) @data = attributes[:data] || raise(ArgumentError.new(":data is required")) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
13 14 15 |
# File 'lib/timber/contexts/custom.rb', line 13 def data @data end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/timber/contexts/custom.rb', line 13 def type @type end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
20 21 22 |
# File 'lib/timber/contexts/custom.rb', line 20 def as_json( = {}) {Timber::Util::Object.try(type, :to_sym) => data} end |