Class: Atmos::AttributeHashBase

Inherits:
Hash
  • Object
show all
Defined in:
lib/atmos/attributes.rb

Overview

AttributeHashBase

Base class for ACL and Metadata objects. Contains utility methods common to both, as well as implementations of standard ruby Hash functions to make both ACL and Metadata objects appear as hashes while interacting with Atmos at the same time.

Direct Known Subclasses

ACL, Metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_reload_atObject (readonly)

:nodoc:



12
13
14
# File 'lib/atmos/attributes.rb', line 12

def last_reload_at
  @last_reload_at
end

Instance Method Details

#clear_with_atmosObject Also known as: clear



29
30
31
# File 'lib/atmos/attributes.rb', line 29

def clear_with_atmos
   clear_without_atmos
end

#default_with_atmos=Object Also known as: default=

Raises:

  • (Atmos::Exceptions::NotImplementedExceptions)


68
69
70
# File 'lib/atmos/attributes.rb', line 68

def default_with_atmos=
   raise Atmos::Exceptions::NotImplementedExceptions, "Not implemented for Atmos Object properties."
end

#delete_with_atmos(key) ⇒ Object Also known as: delete



22
23
24
# File 'lib/atmos/attributes.rb', line 22

def delete_with_atmos(key)
   delete_without_atmos(key)
end

#header_nameObject

This method is used internally to generate REST requests to the Atmos server.

Each ACL or Metadata object knows what HTTP header it is representing in the Atmos REST API we’re wrapping. This method returns that.



89
90
91
# File 'lib/atmos/attributes.rb', line 89

def header_name
   return @header
end

#header_valueObject

This method is used internally to generate REST requests to the Atmos server.

Returns data as a String in the form of a valid HTTP header Atmos will recognize.



100
101
102
# File 'lib/atmos/attributes.rb', line 100

def header_value
   Atmos::Util.hash2header(self)
end

#merge_with_atmos(h) ⇒ Object Also known as: merge



44
45
46
47
# File 'lib/atmos/attributes.rb', line 44

def merge_with_atmos(h)
   validate_input_hash(h)
   merge_without_atmos(h)
end

#merge_with_atmos!(h) ⇒ Object Also known as: merge!



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/atmos/attributes.rb', line 52

def merge_with_atmos!(h)
   validate_input_hash(h)
   
   input = h.clone
   input.each do |k,v|
      input[k] = xlate_value_from_object_to_header(v)
   end
   
   response = @obj.request.do(@set_action, :id => @obj.aoid, @header => Atmos::Util.hash2header(input))
   reload(@reload_action, @obj.aoid)
end

#replace_with_atmos(h) ⇒ Object Also known as: replace



36
37
38
39
# File 'lib/atmos/attributes.rb', line 36

def replace_with_atmos(h)
   validate_input_hash(h)
   replace_without_atmos(h)
end

#store(key, value) ⇒ Object

Same as self = value



78
79
80
# File 'lib/atmos/attributes.rb', line 78

def store(key, value)
   self[key] = value
end

#to_canonicalized_headerObject



112
113
114
# File 'lib/atmos/attributes.rb', line 112

def to_canonicalized_header
   self.to_header.squeeze
end

#to_headerObject

This method is used internally to generate REST requests to the Atmos server.



108
109
110
# File 'lib/atmos/attributes.rb', line 108

def to_header
   "#{self.header_name}: #{self.header_value}"
end