Sha256: 35c56e8408a3101b4ef2aa2bd9749f83610ceaf27ac1113d49ea17f413fed945

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

module Panda
  class Cloud < Base
    include Panda::Updatable
    attr_reader :connection

    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

    class << self
      include Panda::Finders::FindOne

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

      def connection
        Panda.connection
      end
    end

    def eu?
      region == "eu"
    end

    def us?
      region == "us"
    end

    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

    def videos
      VideoScope.new(self)
    end

    def encodings
      EncodingScope.new(self)
    end

    def profiles
      ProfileScope.new(self)
    end

    def method_missing(method_symbol, *arguments)
      lazy_load
      super
    end

    private

    def lazy_load
      @found ||= reload
    end

  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
panda-1.3.0 lib/panda/resources/cloud.rb
panda-1.2.2 lib/panda/resources/cloud.rb
panda-1.2.1 lib/panda/resources/cloud.rb
panda-1.2.0 lib/panda/resources/cloud.rb
panda-1.1.0 lib/panda/resources/cloud.rb
faraday-panda-1.1.0 lib/panda/resources/cloud.rb