Sha256: 4d9cd052e1840b683088f837f4404de4feda981ae42e986fe613eabfa48029e2

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

class FlixCloud::Record

  attr_accessor :errors

  def initialize(attrs={})
    self.errors = []
    self.attributes = attrs
  end

  def attributes=(attrs)
    attrs.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  end

  def self.record_column(attribute, klass)
    eval %{
      attr_reader :#{attribute}

      def #{attribute}=(value)
        if @#{attribute}
          @#{attribute}.attributes = value
        else
          @#{attribute} = FlixCloud::#{klass}.new(value)
        end
      end
    }
  end


protected

  def post(path, body)
    puts "========>https://flixcloud.com/#{path}<=================="
    begin
      FlixCloud::Response.new(HttpClient::Resource.new("https://app.zencoder.com/#{path}",
                                                       :verify_ssl => OpenSSL::SSL::VERIFY_PEER).post(body, :content_type => 'application/xml', :accept => 'application/xml'))
    rescue HttpClient::ServerBrokeConnection
      raise FlixCloud::ServerBrokeConnection, $!.message
    rescue HttpClient::RequestTimeout
      raise FlixCloud::RequestTimeout, $!.message
    rescue HttpClient::ConnectionRefused
      raise FlixCloud::ConnectionRefused, $!.message
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spob-flix_cloud-gem-0.6.2 lib/flix_cloud/record.rb