class AWS::S3::BucketLifecycleConfiguration::Rule
Represents a single rule from an Amazon S3 bucket lifecycle configuration.
# delete all objects with the prefix 'temporary/' after 10 days bucket.lifecycle_configuration.add_rule 'temporary/', 10 # remove the rule created above bucket.lifecycle_configuration.remove_rule 'temporary/'
Attributes
@return [BucketLifecycleConfiguration]
@return [Date] the date the objects will expire @return [Integer] if the value is an integer, returns the number
of days before the object will expire.
@return [Date] the date the objects will expire @return [Integer] if the value is an integer, returns the number
of days before the object will expire.
@return [Date] the date the objects will be
transitioned into the Amazon Glacier storage tier.
@return [Integer] if the value is an integer, returns the number
of days before the object is transitioned into the Amazon Glacier storage tier.
@return [String]
@return [Integer]
@return [Integer]
@return [String]
@return [String] Returns the rule status, 'Enabled' or 'Disabled'
Public Class Methods
@api private
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 346 def initialize configuration, id, prefix, expiration_time = nil, status = nil @configuration = configuration @id = id @prefix = prefix if Hash === expiration_time options = expiration_time options.each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end else self.expiration_time = expiration_time self.status = status end end
Public Instance Methods
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 417 def disabled! self.status = 'Disabled' end
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 413 def disabled? status == 'Disabled' end
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 409 def enable! self.status = 'Enabled' end
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 405 def enabled? status == 'Enabled' end
@api private
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 422 def eql? other other.is_a?(Rule) and other.configuration.bucket == configuration.bucket and other.id == id and other.prefix == prefix and other.expiration_time == expiration_time and other.glacier_transition_time == glacier_transition_time and other.status == status and other.noncurrent_version_transition_days == noncurrent_version_transition_days and other.noncurrent_version_expiration_days == noncurrent_version_expiration_days end
Converts any time values to Date objects
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 377 def expiration_time=(value) @expiration_time = convert_time_value(value) end
Converts any time values to Date objects
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 392 def glacier_transition_time=(value) @glacier_transition_time = convert_time_value(value) end
Private Instance Methods
If an integer, returns the integer as days, otherwise converts any time-like values into Date objects @return [Integer] if the value is an integer @return [Date] if the value is a time-like object @return [nil] if the value is nil
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 442 def convert_time_value(value) return nil if value.nil? return value if value.is_a?(Integer) Date.parse(value.to_s) end