Class: Aliyun::Oss::Struct::LifeCycle
- Defined in:
- lib/aliyun/oss/struct/lifecycle.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Set auto auto delete object at given time, at least exist one with days, [Time].
-
#days ⇒ Object
Set auto delete objects after days since last modified, at least exist one with date [Integer].
-
#enabled ⇒ Object
Used for set rule status.
-
#id ⇒ Object
Rule ID, auto set when not set.
-
#prefix ⇒ Object
Used for filter objects.
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Aliyun::Oss::Struct::Base
Instance Attribute Details
#date ⇒ Object
Set auto auto delete object at given time, at least exist one with days, [Time]
18 19 20 |
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 18 def date @date end |
#days ⇒ Object
Set auto delete objects after days since last modified, at least exist one with date [Integer]
15 16 17 |
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 15 def days @days end |
#enabled ⇒ Object
Used for set rule status. [Boolean]
12 13 14 |
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 12 def enabled @enabled end |
#id ⇒ Object
Rule ID, auto set when not set. [String]
6 7 8 |
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 6 def id @id end |
#prefix ⇒ Object
Used for filter objects. [String]
9 10 11 |
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 9 def prefix @prefix end |
Instance Method Details
#expiration=(expiration) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 43 def expiration=(expiration) return unless expiration.is_a?(Hash) if expiration.key?('Days') self.days = expiration['Days'] elsif expiration.key?('Date') self.date = expiration['Date'] end end |
#status=(status) ⇒ Object
20 21 22 |
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 20 def status=(status) @enabled = (status == 'Enabled') end |
#to_hash ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 32 def to_hash return {} unless valid? { 'ID' => id || '', 'Prefix' => prefix, 'Status' => status, 'Expiration' => expiration } end |
#valid? ⇒ Boolean
53 54 55 |
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 53 def valid? prefix && (days || date) end |