Class: Dropbox::API::Object

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/dropbox-api/objects/object.rb

Direct Known Subclasses

Dir, File

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/dropbox-api/objects/object.rb', line 5

def client
  @client
end

Class Method Details

.convert(array_or_object, client) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/dropbox-api/objects/object.rb', line 17

def self.convert(array_or_object, client)
  if array_or_object.is_a?(Array)
    array_or_object.collect do |item|
      resolve_class(item).init(item, client)
    end
  else
    resolve_class(array_or_object).init(array_or_object, client)
  end
end

.init(response, client) ⇒ Object



7
8
9
10
11
# File 'lib/dropbox-api/objects/object.rb', line 7

def self.init(response, client)
  instance = self.new(response)
  instance.client = client
  instance
end

.resolve_class(hash) ⇒ Object



13
14
15
# File 'lib/dropbox-api/objects/object.rb', line 13

def self.resolve_class(hash)
  hash['is_dir'] == true ? Dropbox::API::Dir : Dropbox::API::File
end

Instance Method Details

#deep_update(other_hash) ⇒ Object

Kill off the ability for recursive conversion



28
29
30
31
32
33
34
# File 'lib/dropbox-api/objects/object.rb', line 28

def deep_update(other_hash)
  other_hash.each_pair do |k,v|
    key = convert_key(k)
    regular_writer(key, convert_value(v, true))
  end
  self
end