Class: LogStruct::Log::Shrine::Upload

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Includes:
Interfaces::CommonFields, LogStruct::Log::Shared::SerializeCommon
Defined in:
lib/log_struct/log/shrine/upload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LogStruct::Log::Shared::SerializeCommon

#as_json, #serialize, #serialize_common

Methods included from Interfaces::CommonFieldBase

#serialize

Constructor Details

#initialize(source: Source::Shrine, event: Event::Upload, timestamp:, level: Level::Info, storage:, location:, mime_type: nil, size: nil, upload_options: nil, options: nil, uploader: nil, duration_ms: nil) ⇒ void

Parameters:

  • source (Source::Shrine) (defaults to: Source::Shrine) —

    Shared/common fields

  • event (Event) (defaults to: Event::Upload)
  • timestamp (Time)
  • level (Level) (defaults to: Level::Info)
  • storage (Symbol) —

    Event-specific fields

  • location (String)
  • mime_type (String, nil) (defaults to: nil)
  • size (Integer, nil) (defaults to: nil)
  • upload_options (Hash{Symbol => T.untyped}, nil) (defaults to: nil)
  • options (Hash{Symbol => T.untyped}, nil) (defaults to: nil)
  • uploader (String, nil) (defaults to: nil)
  • duration_ms (Float, nil) (defaults to: nil)


# File ''

const :source, Source::Shrine, default: Source::Shrine
const :event, Event, default: Event::Upload
const :timestamp, Time, factory: -> { Time.now }
const :level, Level, default: Level::Info
const :storage, Symbol
const :location, String
const :mime_type, T.nilable(String), default: nil
const :size, T.nilable(Integer), default: nil
const :upload_options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil
const :options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil
const :uploader, T.nilable(String), default: nil
const :duration_ms, T.nilable(Float), default: nil

Instance Attribute Details

#duration_ms ⇒ Float? (readonly)

Returns the value of prop duration_ms.

Returns:

  • (Float, nil)


# File ''

const :duration_ms, T.nilable(Float), default: nil

#event ⇒ Event (readonly)

Returns the value of prop event.

Returns:



# File ''

const :event, Event, default: Event::Upload

#level ⇒ Level (readonly)

Returns the value of prop level.

Returns:



# File ''

const :level, Level, default: Level::Info

#location ⇒ String (readonly)

Returns the value of prop location.

Returns:

  • (String)


# File ''

const :location, String

#mime_type ⇒ String? (readonly)

Returns the value of prop mime_type.

Returns:

  • (String, nil)


# File ''

const :mime_type, T.nilable(String), default: nil

#options ⇒ Hash{Symbol => T.untyped}? (readonly)

Returns the value of prop options.

Returns:

  • (Hash{Symbol => T.untyped}, nil)


# File ''

const :options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil

#size ⇒ Integer? (readonly)

Returns the value of prop size.

Returns:

  • (Integer, nil)


# File ''

const :size, T.nilable(Integer), default: nil

#source ⇒ Source::Shrine (readonly)

Shared/common fields

Returns:



# File ''

const :source, Source::Shrine, default: Source::Shrine

#storage ⇒ Symbol (readonly)

Event-specific fields

Returns:

  • (Symbol)


# File ''

const :storage, Symbol

#timestamp ⇒ Time (readonly)

Returns the value of prop timestamp.

Returns:

  • (Time)


# File ''

const :timestamp, Time, factory: -> { Time.now }

#upload_options ⇒ Hash{Symbol => T.untyped}? (readonly)

Returns the value of prop upload_options.

Returns:

  • (Hash{Symbol => T.untyped}, nil)


# File ''

const :upload_options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil

#uploader ⇒ String? (readonly)

Returns the value of prop uploader.

Returns:

  • (String, nil)


# File ''

const :uploader, T.nilable(String), default: nil

Instance Method Details

#to_h ⇒ Hash{LogStruct::LogField => T.untyped}

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/log_struct/log/shrine/upload.rb', line 47

def to_h
  h = T.let({}, T::Hash[LogStruct::LogField, T.untyped])
  h[LogField::Storage] = storage
  h[LogField::Location] = location
  h[LogField::MimeType] = mime_type unless mime_type.nil?
  h[LogField::Size] = size unless size.nil?
  h[LogField::UploadOptions] = upload_options unless upload_options.nil?
  h[LogField::Options] = options unless options.nil?
  h[LogField::Uploader] = uploader unless uploader.nil?
  h[LogField::DurationMs] = duration_ms unless duration_ms.nil?
  h
end