Class: Duracloud::Properties
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Duracloud::Properties
- Defined in:
- lib/duracloud/properties.rb
Overview
Encapsulates Duracloud “properties” which are transmitted via HTTP headers.
Direct Known Subclasses
Constant Summary collapse
- PREFIX =
"x-dura-meta-".freeze
Class Method Summary collapse
-
.property?(prop) ⇒ Boolean
Is the property name valid?.
Instance Method Summary collapse
- #convert_value(value, _ = nil) ⇒ Object private
-
#initialize(source = nil, default = nil, &block) ⇒ Properties
constructor
A new instance of Properties.
- #property?(prop) ⇒ Boolean
Constructor Details
#initialize(source = nil, default = nil, &block) ⇒ Properties
Returns a new instance of Properties.
20 21 22 23 |
# File 'lib/duracloud/properties.rb', line 20 def initialize(source = nil, default = nil, &block) source.select! { |k, v| property?(k) } if source super end |
Class Method Details
.property?(prop) ⇒ Boolean
Is the property name valid?
16 17 18 |
# File 'lib/duracloud/properties.rb', line 16 def self.property?(prop) prop.to_s.start_with?(PREFIX) end |
Instance Method Details
#convert_value(value, _ = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/duracloud/properties.rb', line 30 def convert_value(value, _ = nil) case value when Array convert_array(value) when Time value.utc.iso8601 when DateTime convert_value(value.to_time) else force_ascii(value.to_s) end end |
#property?(prop) ⇒ Boolean
25 26 27 |
# File 'lib/duracloud/properties.rb', line 25 def property?(prop) self.class.property?(prop) end |