Class: AMON::Document Abstract

Inherits:
Object
  • Object
show all
Includes:
JSONHelper
Defined in:
lib/amon/document.rb

Overview

This class is abstract.

A top-level object representing an AMON resource

Direct Known Subclasses

Device, Entity, MeteringPoint

Instance Attribute Summary collapse

Attributes included from JSONHelper

#json

Instance Method Summary collapse

Constructor Details

#initialize(session, json) ⇒ Document

Returns a new instance of Document.

Parameters:

  • session (Session)

    The session

  • json (Hash)

    The JSON data as a Hash



12
13
14
# File 'lib/amon/document.rb', line 12

def initialize(session, json)
  @session, @json = session, json
end

Instance Attribute Details

#sessionSession (readonly)

Returns The session associated with this document.

Returns:

  • (Session)

    The session associated with this document



8
9
10
# File 'lib/amon/document.rb', line 8

def session
  @session
end

Instance Method Details

#==(other) ⇒ Boolean

Two documents are equal if they have the same class and their id fields are equal

Parameters:

Returns:

  • (Boolean)


26
27
28
# File 'lib/amon/document.rb', line 26

def ==(other)
  self.class == other.class && id == other.id
end

#idObject

This method is abstract.

This should be implemented in subclasses, returning the UUID for the document

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/amon/document.rb', line 19

def id
  raise NotImplementedError
end