Sha256: 2a40f92fde973fa81652e1e0fe40f784ba49b0b8e6b3c0e9b523a994f9d76862

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 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'].blank? 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.2 lib/iknow/model/base.rb