Class: Oss::Service
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#xml_obj ⇒ Object
Returns the value of attribute xml_obj.
Instance Method Summary collapse
- #buckets ⇒ Object
-
#get_service(options = {}) ⇒ Object
params: - options: - prefix - marker - max_keys.
-
#initialize(client) ⇒ Service
constructor
A new instance of Service.
-
#method_missing(method) ⇒ Object
prefix, marker, max_keys, is_truncated, next_marker.
- #owner ⇒ Object
Methods included from Util
#camelize, #hash_filter, #oss_headers_to_s, #set_query_string
Constructor Details
#initialize(client) ⇒ Service
Returns a new instance of Service.
14 15 16 |
# File 'lib/oss/service.rb', line 14 def initialize(client) @client = client end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
prefix, marker, max_keys, is_truncated, next_marker
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/oss/service.rb', line 50 def method_missing(method) if @xml_obj.nil? super else camel = Util.camelize(method) value = @xml_obj.xpath(camel) raise "missing xml attribute #{camel}" if value.length == 0 value.inner_text end end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
12 13 14 |
# File 'lib/oss/service.rb', line 12 def client @client end |
#xml_obj ⇒ Object
Returns the value of attribute xml_obj.
12 13 14 |
# File 'lib/oss/service.rb', line 12 def xml_obj @xml_obj end |
Instance Method Details
#buckets ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/oss/service.rb', line 36 def buckets buckets = @xml_obj.xpath('Buckets') results = Array.new buckets.each do |bucket| results << { :location => bucket.xpath('Bucket/Location').text, :name => bucket.xpath('Bucket/Name').text, :creation_date => bucket.xpath('Bucket/CreationDate').text } end results end |
#get_service(options = {}) ⇒ Object
params:
-
options:
-
prefix
-
marker
-
max_keys
-
23 24 25 26 |
# File 'lib/oss/service.rb', line 23 def get_service( = {}) @xml_obj = client.get(host: SERVICE_HOST, path: '/', query_string: ).xpath('ListAllMyBucketsResult') self end |
#owner ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/oss/service.rb', line 28 def owner owner = @xml_obj.xpath('Owner') { :id => owner.xpath('ID').text, :display_name => owner.xpath('DisplayName').text } end |