Class: Google::Storage::Data::BucketRule

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/google/storage/property/bucket_rule.rb

Overview

A class to manage data for Rule for bucket.

Direct Known Subclasses

BucketRuleApi, BucketRuleCatalog

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



38
39
40
# File 'lib/google/storage/property/bucket_rule.rb', line 38

def action
  @action
end

#conditionObject (readonly)

Returns the value of attribute condition.



39
40
41
# File 'lib/google/storage/property/bucket_rule.rb', line 39

def condition
  @condition
end

Instance Method Details

#<=>(other) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/google/storage/property/bucket_rule.rb', line 64

def <=>(other)
  return false unless other.is_a? BucketRule
  compare_fields(other).each do |compare|
    next if compare[:self].nil? || compare[:other].nil?
    result = compare[:self] <=> compare[:other]
    return result unless result.zero?
  end
  0
end

#==(other) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/google/storage/property/bucket_rule.rb', line 55

def ==(other)
  return false unless other.is_a? BucketRule
  compare_fields(other).each do |compare|
    next if compare[:self].nil? || compare[:other].nil?
    return false if compare[:self] != compare[:other]
  end
  true
end

#to_json(_arg = nil) ⇒ Object



41
42
43
44
45
46
# File 'lib/google/storage/property/bucket_rule.rb', line 41

def to_json(_arg = nil)
  {
    'action' => action,
    'condition' => condition
  }.reject { |_k, v| v.nil? }.to_json
end

#to_sObject



48
49
50
51
52
53
# File 'lib/google/storage/property/bucket_rule.rb', line 48

def to_s
  {
    action: action,
    condition: condition
  }.reject { |_k, v| v.nil? }.map { |k, v| "#{k}: #{v}" }.join(', ')
end