Sha256: 1424228b982c4080bfd52239448c18418daefaad21d34eddfd4f834affe4f36a

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 Bytes

Contents

class Iknow::Base

  def self.attributes; self::ATTRIBUTES end

  def attributes; self.class.attributes  end

  def self.deserialize(response, params = {})
    return nil if response.is_a?(Hash) and
                 !response['error'].nil? and
                  response['error']['code'].to_i == 404

    klass = params[:as]   ? params[:as] : self
    response.is_a?(Array) ? response.inject([]) { |results, params| results << klass.new(params) } :
                            klass.new(response)
  end

  def deserialize(response, params = {})
    self.class.deserialize(response, params)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nov-iknow-0.0.3 lib/iknow/model/base.rb