Sha256: a1a9420b938d1831ee12b059896ea52ce45cca0513fef35f2110982aded1685a

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 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://flixcloud.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.1 lib/flix_cloud/record.rb