Class: Hackle::PropertiesBuilder
- Inherits:
-
Object
- Object
- Hackle::PropertiesBuilder
- Defined in:
- lib/hackle/internal/properties/properties_builder.rb
Instance Method Summary collapse
- #add(key, value) ⇒ Hackle::PropertiesBuilder
- #add_all(properties) ⇒ Hackle::PropertiesBuilder
-
#build ⇒ Hash{String (frozen)->Object
].
-
#initialize ⇒ PropertiesBuilder
constructor
A new instance of PropertiesBuilder.
Constructor Details
#initialize ⇒ PropertiesBuilder
Returns a new instance of PropertiesBuilder.
7 8 9 10 |
# File 'lib/hackle/internal/properties/properties_builder.rb', line 7 def initialize # @type [Hash{String => Object}] @properties = {} end |
Instance Method Details
#add(key, value) ⇒ Hackle::PropertiesBuilder
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hackle/internal/properties/properties_builder.rb', line 15 def add(key, value) return self if @properties.length >= MAX_PROPERTIES_COUNT unless valid_key?(key) Log.get.warn { "Invalid property key: #{key} (expected: string[1..128])" } return self end sanitized_value = sanitize_value_or_nil(key, value) @properties[key] = sanitized_value unless sanitized_value.nil? self end |
#add_all(properties) ⇒ Hackle::PropertiesBuilder
30 31 32 33 34 35 36 37 38 |
# File 'lib/hackle/internal/properties/properties_builder.rb', line 30 def add_all(properties) if properties.nil? || !properties.is_a?(Hash) Log.get.warn { "Invalid properties: #{properties} (expected: Hash{String => Object})" } return self end properties.each { |key, value| add(key, value) } self end |
#build ⇒ Hash{String (frozen)->Object
Returns ].
41 42 43 |
# File 'lib/hackle/internal/properties/properties_builder.rb', line 41 def build @properties.dup end |