Sha256: 1b512fde621bc2f8f6be1157dc09773bbefedd7afc2476f6ee4af30e5f1f46de

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

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)
    RestClient::Resource.new(
      "https://flixcloud.com/#{path}",
      :verify_ssl => OpenSSL::SSL::VERIFY_PEER).post(body, :content_type => 'application/xml', :accept => 'application/xml')
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zencoder-flix_cloud-gem-0.0.0 lib/flix_cloud/record.rb
zencoder-flix_cloud-gem-0.1.1 lib/flix_cloud/record.rb