Class: CloudwatchQuery::Result
- Inherits:
-
Object
- Object
- CloudwatchQuery::Result
show all
- Defined in:
- lib/cloudwatch_query/result.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data, registry: nil) ⇒ Result
Returns a new instance of Result.
7
8
9
10
11
12
13
|
# File 'lib/cloudwatch_query/result.rb', line 7
def initialize(data, registry: nil)
@data = data.transform_keys(&:to_sym)
@registry = registry
@parsed = nil
@parser_name = nil
parse_message! if @registry
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
53
54
55
56
57
58
|
# File 'lib/cloudwatch_query/result.rb', line 53
def method_missing(method_name, *args)
key = method_name.to_sym
return @data[key] if @data.key?(key)
super
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5
6
7
|
# File 'lib/cloudwatch_query/result.rb', line 5
def data
@data
end
|
#parsed ⇒ Object
Returns the value of attribute parsed.
5
6
7
|
# File 'lib/cloudwatch_query/result.rb', line 5
def parsed
@parsed
end
|
#parser_name ⇒ Object
Returns the value of attribute parser_name.
5
6
7
|
# File 'lib/cloudwatch_query/result.rb', line 5
def parser_name
@parser_name
end
|
Instance Method Details
#[](key) ⇒ Object
31
32
33
|
# File 'lib/cloudwatch_query/result.rb', line 31
def [](key)
@data[key.to_sym]
end
|
#log ⇒ Object
27
28
29
|
# File 'lib/cloudwatch_query/result.rb', line 27
def log
@data[:log]
end
|
#log_stream ⇒ Object
23
24
25
|
# File 'lib/cloudwatch_query/result.rb', line 23
def log_stream
@data[:logStream]
end
|
#log_type ⇒ Object
Get the type of parsed log (e.g., :rails_request, :sidekiq)
45
46
47
|
# File 'lib/cloudwatch_query/result.rb', line 45
def log_type
@parsed&.type
end
|
#message ⇒ Object
19
20
21
|
# File 'lib/cloudwatch_query/result.rb', line 19
def message
@data[:message]
end
|
#parsed? ⇒ Boolean
Check if message was successfully parsed
40
41
42
|
# File 'lib/cloudwatch_query/result.rb', line 40
def parsed?
!@parsed.nil?
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
49
50
51
|
# File 'lib/cloudwatch_query/result.rb', line 49
def respond_to_missing?(method_name, include_private = false)
@data.key?(method_name.to_sym) || super
end
|
#timestamp ⇒ Object
15
16
17
|
# File 'lib/cloudwatch_query/result.rb', line 15
def timestamp
@data[:timestamp]
end
|
#to_h ⇒ Object
35
36
37
|
# File 'lib/cloudwatch_query/result.rb', line 35
def to_h
@data.dup
end
|