Sha256: 59677d21ee0a58695c6b7cac096aa444887bdee05285b1509d16cd30353d17d3

Contents?: true

Size: 524 Bytes

Versions: 11

Compression:

Stored size: 524 Bytes

Contents

class Iknow::Base

  def self.attributes; self::ATTRIBUTES end

  def attributes; self.class.attributes  end

  def self.deserialize(hash, params = {})
    return nil if hash.nil?

    klass = params[:as] ? params[:as] : self
    if hash.is_a?(Array)
      hash.inject([]) { |results, hash|
        hash.symbolize_keys!
        results << klass.new(hash)
      }
    else
      hash.symbolize_keys!
      klass.new(hash)
    end
  end

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

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
nov-iknow-0.1.1 lib/iknow/model/base.rb
nov-iknow-0.2.0 lib/iknow/model/base.rb
nov-iknow-0.2.2 lib/iknow/model/base.rb
nov-iknow-0.2.3 lib/iknow/model/base.rb
nov-iknow-0.2.4 lib/iknow/model/base.rb
iknow-0.2.1 lib/iknow/model/base.rb
iknow-0.2.4 lib/iknow/model/base.rb
iknow-0.1.1 lib/iknow/model/base.rb
iknow-0.2.0 lib/iknow/model/base.rb
iknow-0.2.2 lib/iknow/model/base.rb
iknow-0.2.3 lib/iknow/model/base.rb