Class: Panda::Cloud

Inherits:
Base
  • Object
show all
Extended by:
Finders::FindOne
Includes:
Updatable
Defined in:
lib/panda/resources/cloud.rb

Constant Summary

Constants included from Router

Router::DEFAULT_FORMAT, Router::VAR_PATTERN

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #errors

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Finders::FindOne

find, find_by_path, find_object_by_path

Methods included from Updatable

#save, #save!, #update, #update_attribute, #update_attributes

Methods inherited from Base

#changed?, #delete, end_class_name, id, #id, #id=, #new?, #reload, #to_json

Methods included from Router

included, #object_url_map

Constructor Details

#initialize(attributes = {}) ⇒ Cloud

Returns a new instance of Cloud.



6
7
8
9
10
11
# File 'lib/panda/resources/cloud.rb', line 6

def initialize(attributes={})
  super(attributes)
  connection_params = Panda.connection.to_hash.merge!(:cloud_id => id, :format => :hash)
  @connection = Connection.new(connection_params)
  Panda.clouds[id] = self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_symbol, *arguments) ⇒ Object



50
51
52
53
# File 'lib/panda/resources/cloud.rb', line 50

def method_missing(method_symbol, *arguments)
  lazy_load
  super
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



4
5
6
# File 'lib/panda/resources/cloud.rb', line 4

def connection
  @connection
end

Class Method Details

.connectionObject



20
21
22
# File 'lib/panda/resources/cloud.rb', line 20

def connection
  Panda.connection
end

.find(id, options = nil) ⇒ Object



16
17
18
# File 'lib/panda/resources/cloud.rb', line 16

def find(id, options=nil)
  super(id)
end

Instance Method Details

#encodingsObject



42
43
44
# File 'lib/panda/resources/cloud.rb', line 42

def encodings
  EncodingScope.new(self)
end

#eu?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/panda/resources/cloud.rb', line 25

def eu?
  region == "eu"
end

#profilesObject



46
47
48
# File 'lib/panda/resources/cloud.rb', line 46

def profiles
  ProfileScope.new(self)
end

#regionObject



33
34
35
36
# File 'lib/panda/resources/cloud.rb', line 33

def region
  return "eu" if connection.api_host == Panda::Connection::EU_API_HOST
  return "us" if connection.api_host == Panda::Connection::US_API_HOST
end

#us?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/panda/resources/cloud.rb', line 29

def us?
  region == "us"
end

#videosObject



38
39
40
# File 'lib/panda/resources/cloud.rb', line 38

def videos
  VideoScope.new(self)
end