Class: AWS::S3::ObjectMetadata
- Inherits:
-
Object
- Object
- AWS::S3::ObjectMetadata
- Defined in:
- lib/aws/s3/object_metadata.rb
Overview
Returns an object that represents the metadata for an S3 object.
Instance Attribute Summary collapse
- #object ⇒ S3Object readonly
Instance Method Summary collapse
-
#[](name) ⇒ String?
Returns the value for the given name stored in the S3Objects metadata:.
-
#initialize(object, options = {}) ⇒ ObjectMetadata
constructor
A new instance of ObjectMetadata.
-
#method_missing(name) ⇒ String?
Proxies the method to #[].
-
#to_h ⇒ Hash
Returns the user-generated metadata stored with this S3 Object.
Constructor Details
#initialize(object, options = {}) ⇒ ObjectMetadata
Returns a new instance of ObjectMetadata.
28 29 30 31 32 |
# File 'lib/aws/s3/object_metadata.rb', line 28 def initialize(object, = {}) @object = object @version_id = [:version_id] super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ String?
Proxies the method to #[].
50 51 52 |
# File 'lib/aws/s3/object_metadata.rb', line 50 def method_missing name self[name] end |
Instance Attribute Details
#object ⇒ S3Object (readonly)
35 36 37 |
# File 'lib/aws/s3/object_metadata.rb', line 35 def object @object end |
Instance Method Details
#[](name) ⇒ String?
Returns the value for the given name stored in the S3Objects metadata:
bucket.objects['myobject'].['purpose']
# returns nil if the given metadata key has not been set
44 45 46 |
# File 'lib/aws/s3/object_metadata.rb', line 44 def [] name to_h[name.to_s] end |
#to_h ⇒ Hash
Returns the user-generated metadata stored with this S3 Object.
56 57 58 59 60 61 62 |
# File 'lib/aws/s3/object_metadata.rb', line 56 def to_h = {} [:bucket_name] = object.bucket.name [:key] = object.key [:version_id] = @version_id if @version_id client.head_object(). end |