Class: Metriksd::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/metriksd/data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Data

Returns a new instance of Data.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/metriksd/data.rb', line 7

def initialize(data)
  data = HashWithIndifferentAccess.new(data)

  unless @time = data.delete(:time)
    raise ArgumentError, "No 'time' was found"
  end

  unless @client_id = data.delete(:client_id)
    raise ArgumentError, "No 'client_id' was found"
  end

  unless @name = data.delete(:name)
    raise ArgumentError, "No 'name' was found"
  end

  @payload = data
end

Instance Attribute Details

#client_idObject (readonly)

Returns the value of attribute client_id.



5
6
7
# File 'lib/metriksd/data.rb', line 5

def client_id
  @client_id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/metriksd/data.rb', line 5

def name
  @name
end

#payloadObject (readonly)

Returns the value of attribute payload.



5
6
7
# File 'lib/metriksd/data.rb', line 5

def payload
  @payload
end

#timeObject (readonly)

Returns the value of attribute time.



5
6
7
# File 'lib/metriksd/data.rb', line 5

def time
  @time
end

Instance Method Details

#[](key) ⇒ Object



25
26
27
# File 'lib/metriksd/data.rb', line 25

def [](key)
  @payload[key]
end