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

Instance Method Summary collapse

Methods included from Thingfish::Normalization

make_object_id, normalize_key, normalize_keys, normalize_oid

Instance Attribute Details

#metadataObject (readonly)

The Hash of Thingfish metadata associated with the request



36
37
38
# File 'lib/strelka/httprequest/metadata.rb', line 36

def 
  @metadata
end

The Hash of related resources



39
40
41
# File 'lib/strelka/httprequest/metadata.rb', line 39

def related_resources
  @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 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 add_related_resource( io,  )
	 = normalize_keys(  )
	.merge!( self.(io) )
	self.log.debug "Adding related resource: %p %p" % [ io,  ]
	self.related_resources[ io ] = 
end

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

#initializeObject

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