Class: SolidCacheDashboard::Decorators::CacheEventDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_cache_dashboard/decorators/cache_event_decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ CacheEventDecorator

Returns a new instance of CacheEventDecorator.



4
5
6
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 4

def initialize(event)
  @event = event
end

Instance Method Details

#byte_sizeObject



24
25
26
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 24

def byte_size
  @event.byte_size
end

#colorObject



46
47
48
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 46

def color
  @event.color
end

#created_atObject



42
43
44
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 42

def created_at
  @event.created_at
end

#created_at_agoObject



50
51
52
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 50

def created_at_ago
  time_ago_in_words(created_at)
end

#durationObject



33
34
35
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 33

def duration
  @event.duration
end

#event_typeObject



12
13
14
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 12

def event_type
  @event.event_type
end

#human_byte_sizeObject



28
29
30
31
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 28

def human_byte_size
  return nil unless @event.byte_size
  ActiveSupport::NumberHelper.number_to_human_size(@event.byte_size)
end

#human_durationObject



37
38
39
40
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 37

def human_duration
  return nil unless @event.duration
  "#{(@event.duration * 1000).round(2)} ms"
end

#idObject



8
9
10
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 8

def id
  @event.id
end

#key_hashObject



16
17
18
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 16

def key_hash
  @event.key_hash
end

#key_stringObject



20
21
22
# File 'lib/solid_cache_dashboard/decorators/cache_event_decorator.rb', line 20

def key_string
  @event.key_string || @event.key_hash.to_s
end