Class: Panda::Cloud

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

Constant Summary

Constants included from Router

Router::VAR_PATTERN

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #errors

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Updatable

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

Methods inherited from Base

#changed?, #id, #id=, #new?, #reload, sti_name

Methods included from Finders

included

Methods included from Builders

#create, #create!, included

Methods included from Router

included, #replace_pattern_with_self_variables

Constructor Details

#initialize(attributes = {}) ⇒ Cloud



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

def initialize(attributes={})
  super(attributes)
  connection_params = Panda.connection.to_hash.merge!(:cloud_id => id)
  @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



52
53
54
55
# File 'lib/panda/resources/cloud.rb', line 52

def method_missing(method_symbol, *arguments)
  lazy_load
  super
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

Class Method Details

.connectionObject



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

def connection
  Panda.connection
end

Instance Method Details

#encodingsObject



44
45
46
# File 'lib/panda/resources/cloud.rb', line 44

def encodings
  EncodingScope.new(self)
end

#eu?Boolean



27
28
29
# File 'lib/panda/resources/cloud.rb', line 27

def eu?
  region == "eu"
end

#profilesObject



48
49
50
# File 'lib/panda/resources/cloud.rb', line 48

def profiles
  ProfileScope.new(self)
end

#regionObject



35
36
37
38
# File 'lib/panda/resources/cloud.rb', line 35

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

#us?Boolean



31
32
33
# File 'lib/panda/resources/cloud.rb', line 31

def us?
  region == "us"
end

#videosObject



40
41
42
# File 'lib/panda/resources/cloud.rb', line 40

def videos
  VideoScope.new(self)
end