Module: AMON
- Extended by:
- Forwardable
- Defined in:
- lib/amon/default_session.rb,
lib/amon.rb,
lib/amon/device.rb,
lib/amon/entity.rb,
lib/amon/reading.rb,
lib/amon/session.rb,
lib/amon/version.rb,
lib/amon/document.rb,
lib/amon/metadata.rb,
lib/amon/json_helper.rb,
lib/amon/measurement.rb,
lib/amon/document_part.rb,
lib/amon/metering_point.rb
Overview
The AMON module responds to the same method names as an Session. When called, these methods use a ‘default’ session returned by AMON.create_default_session. So the following method calls are all equivalent:
AMON::Session.new(AMON.).entity("77e50660-93e7-012d-b57d-001c23973687")
AMON.create_default_session.entity("77e50660-93e7-012d-b57d-001c23973687")
AMON.entity("77e50660-93e7-012d-b57d-001c23973687")
Note that using a default session implicitly (as in the final line above) will cause a new session to be created each time the method is called. This means caching will not be used.
If you are likely to be requesting the same resources in short succession, it is advisable to hold on to a session object yourself. For example:
@session = AMON.create_default_session
@session.entity("77e50660-93e7-012d-b57d-001c23973687") # => <AMON::Entity> (from HTTP)
@session.entity("77e50660-93e7-012d-b57d-001c23973687") # => <AMON::Entity> (from cache)
Defined Under Namespace
Modules: JSONHelper, Version Classes: Device, Document, DocumentPart, Entity, Measurement, Metadata, MeteringPoint, Reading, Session
Class Method Summary collapse
-
.create_default_session ⇒ Session
Creates a new session using the AMON.default_session_options.
-
.default_session_options ⇒ Hash
A hash of options which are used by AMON.create_default_session.
-
.default_session_options=(options) ⇒ Hash
Assigns a new options hash as the AMON.default_session_options.
Class Method Details
.create_default_session ⇒ Session
Creates a new session using the default_session_options.
38 39 40 |
# File 'lib/amon/default_session.rb', line 38 def create_default_session Session.new() end |
.default_session_options ⇒ Hash
A hash of options which are used by create_default_session. The values of this hash should be configured by users as appropriate.
25 26 27 |
# File 'lib/amon/default_session.rb', line 25 def @default_session_options ||= {} end |
.default_session_options=(options) ⇒ Hash
Assigns a new options hash as the default_session_options.
32 33 34 |
# File 'lib/amon/default_session.rb', line 32 def () @default_session_options = end |