Class: LogStruct::Log::Shrine::Metadata
- Inherits:
-
T::Struct
- Object
- T::Struct
- LogStruct::Log::Shrine::Metadata
- Extended by:
- T::Sig
- Defined in:
- lib/log_struct/log/shrine/metadata.rb
Instance Attribute Summary collapse
-
#event ⇒ Event
readonly
Returns the value of prop
event. -
#level ⇒ Level
readonly
Returns the value of prop
level. -
#location ⇒ String?
readonly
Returns the value of prop
location. -
#metadata ⇒ Hash{String => T.untyped}?
readonly
Returns the value of prop
metadata. -
#source ⇒ Source::Shrine
readonly
Shared/common fields.
-
#storage ⇒ Symbol
readonly
Event-specific fields.
-
#timestamp ⇒ Time
readonly
Returns the value of prop
timestamp.
Instance Method Summary collapse
- #initialize(source: Source::Shrine, event: Event::Metadata, timestamp:, level: Level::Info, storage:, location: nil, metadata: nil) ⇒ void constructor
- #to_h ⇒ Hash{LogStruct::LogField => T.untyped}
Methods included from LogStruct::Log::Shared::SerializeCommon
#as_json, #serialize, #serialize_common
Methods included from Interfaces::CommonFields
Constructor Details
#initialize(source: Source::Shrine, event: Event::Metadata, timestamp:, level: Level::Info, storage:, location: nil, metadata: nil) ⇒ void
|
|
# File '' const :source, Source::Shrine, default: Source::Shrine const :event, Event, default: Event::Metadata const :timestamp, Time, factory: -> { Time.now } const :level, Level, default: Level::Info const :storage, Symbol const :location, T.nilable(String), default: nil const :metadata, T.nilable(T::Hash[String, T.untyped]), default: nil |
Instance Attribute Details
#event ⇒ Event (readonly)
Returns the value of prop event.
|
|
# File '' const :event, Event, default: Event::Metadata |
#level ⇒ Level (readonly)
Returns the value of prop level.
|
|
# File '' const :level, Level, default: Level::Info |
#location ⇒ String? (readonly)
Returns the value of prop location.
|
|
# File '' const :location, T.nilable(String), default: nil |
#metadata ⇒ Hash{String => T.untyped}? (readonly)
Returns the value of prop metadata.
|
|
# File '' const :metadata, T.nilable(T::Hash[String, T.untyped]), default: nil |
#source ⇒ Source::Shrine (readonly)
Shared/common fields
|
|
# File '' const :source, Source::Shrine, default: Source::Shrine |
#storage ⇒ Symbol (readonly)
Event-specific fields
|
|
# File '' const :storage, Symbol |
#timestamp ⇒ Time (readonly)
Returns the value of prop timestamp.
|
|
# File '' const :timestamp, Time, factory: -> { Time.now } |
Instance Method Details
#to_h ⇒ Hash{LogStruct::LogField => T.untyped}
42 43 44 45 46 47 48 |
# File 'lib/log_struct/log/shrine/metadata.rb', line 42 def to_h h = T.let({}, T::Hash[LogStruct::LogField, T.untyped]) h[LogField::Storage] = storage h[LogField::Location] = location unless location.nil? h[LogField::Metadata] = unless .nil? h end |