Class: Statsby::TagSet

Inherits:
Hash
  • Object
show all
Defined in:
lib/statsby/tag_set.rb

Overview

A set of tags is really just some key value pairs, so we can leverage Ruby’s built-in Hash class, simply overriding ‘#to_s` to get the format that we need. Maybe we can add some validation in the future.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



7
8
9
# File 'lib/statsby/tag_set.rb', line 7

def self.from_hash(hash)
  TagSet.new.merge(hash)
end

Instance Method Details

#to_sObject



11
12
13
# File 'lib/statsby/tag_set.rb', line 11

def to_s
  map { |key, value| "#{key}=#{value}" }.join(',')
end