Module: Strelka::HTTPRequest::Metadata
- Includes:
- Constants, Thingfish::Normalization
- Defined in:
- lib/strelka/httprequest/metadata.rb
Overview
The mixin that adds methods to Strelka::HTTPRequest for Thingfish metadata.
request.
request.
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
The Hash of Thingfish metadata associated with the request.
-
#related_resources ⇒ Object
readonly
The Hash of related resources.
Instance Method Summary collapse
-
#add_metadata(metadata) ⇒ Object
Merge the metadata in the given
metadata
hash into the request’s current metadata. -
#add_related_resource(io, metadata) ⇒ Object
Add a resource that’s related to the one in the request.
-
#extract_related_metadata(io) ⇒ Object
Extract some default metadata from related resources.
-
#initialize ⇒ Object
Set up some data structures for metadata.
Methods included from Thingfish::Normalization
make_object_id, normalize_key, normalize_keys, normalize_oid
Instance Attribute Details
#metadata ⇒ Object (readonly)
The Hash of Thingfish metadata associated with the request
36 37 38 |
# File 'lib/strelka/httprequest/metadata.rb', line 36 def @metadata end |
#related_resources ⇒ Object (readonly)
The Hash of related resources
39 40 41 |
# File 'lib/strelka/httprequest/metadata.rb', line 39 def @related_resources end |
Instance Method Details
#add_metadata(metadata) ⇒ Object
Merge the metadata in the given metadata
hash into the request’s current metadata.
44 45 46 47 48 |
# File 'lib/strelka/httprequest/metadata.rb', line 44 def ( ) self.log.debug "Adding metadata to the request: %p" % [ ] = normalize_keys( ) self..merge!( ) end |
#add_related_resource(io, metadata) ⇒ Object
Add a resource that’s related to the one in the request.
52 53 54 55 56 57 |
# File 'lib/strelka/httprequest/metadata.rb', line 52 def ( io, ) = normalize_keys( ) .merge!( self.(io) ) self.log.debug "Adding related resource: %p %p" % [ io, ] self.[ io ] = end |
#extract_related_metadata(io) ⇒ Object
Extract some default metadata from related resources.
61 62 63 64 65 66 67 |
# File 'lib/strelka/httprequest/metadata.rb', line 61 def ( io ) = {} ['extent'] = io.size return end |
#initialize ⇒ Object
Set up some data structures for metadata.
23 24 25 26 27 28 |
# File 'lib/strelka/httprequest/metadata.rb', line 23 def initialize( * ) super @metadata = {} @related_resources = {} end |