Class: Appsignal::SampleData Private
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #add(data = nil, &block) ⇒ Object private
- #empty? ⇒ Boolean private
-
#initialize(key, accepted_type = nil) ⇒ SampleData
constructor
private
A new instance of SampleData.
- #set_empty_value! ⇒ Object private
- #value ⇒ Object private
- #value? ⇒ Boolean private
Constructor Details
#initialize(key, accepted_type = nil) ⇒ SampleData
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SampleData.
6 7 8 9 10 11 |
# File 'lib/appsignal/sample_data.rb', line 6 def initialize(key, accepted_type = nil) @key = key @accepted_type = accepted_type @blocks = [] @empty = false end |
Instance Method Details
#add(data = nil, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/appsignal/sample_data.rb', line 13 def add(data = nil, &block) @empty = false if block_given? @blocks << block elsif accepted_type?(data) @blocks << data else log_unsupported_data_type(data) end end |
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 |
# File 'lib/appsignal/sample_data.rb', line 56 def empty? @empty end |
#set_empty_value! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 |
# File 'lib/appsignal/sample_data.rb', line 25 def set_empty_value! @empty = true @blocks.clear end |
#value ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/appsignal/sample_data.rb', line 30 def value value = UNSET_VALUE @blocks.map! do |block_or_value| new_value = if block_or_value.respond_to?(:call) block_or_value.call else block_or_value end unless accepted_type?(new_value) log_unsupported_data_type(new_value) next end value = merge_values(value, new_value) new_value end value end |
#value? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/appsignal/sample_data.rb', line 51 def value? @blocks.any? end |