Class: AMON::Metadata
- Inherits:
-
DocumentPart
- Object
- DocumentPart
- AMON::Metadata
- Defined in:
- lib/amon/metadata.rb
Overview
TODO:
This doesn’t yet support arbitrarily nested metadata, so you can’t have JSON like so:
"metadata": {
"foo": {
"bar": "baz"
}
}
And then access:
object..foo. # => "baz"
However, in the meantime you could do:
object..foo[:bar] # => "baz"
(As the JSON is full parsed into a nested hash.)
Metadata associated with a Device. The metadata section of an AMON document can have an arbitrary number of fields, so this class uses method_missing to look them up and respond appropriately.
Instance Attribute Summary
Attributes inherited from DocumentPart
Attributes included from JSONHelper
Instance Method Summary collapse
Methods inherited from DocumentPart
Constructor Details
This class inherits a constructor from AMON::DocumentPart
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/amon/metadata.rb', line 26 def method_missing(name, *args, &block) if args.empty? && block.nil? json[name.to_s] else raise NoMethodError, "undefined method `#{name}'" end end |