Sha256: 132ebcc62781068911c069b6baa003ef31b9a29249d672aa76345c6cce7fe48e

Contents?: true

Size: 538 Bytes

Versions: 6

Compression:

Stored size: 538 Bytes

Contents

class Smartfm::Base

  def self.attributes; self::ATTRIBUTES end
  def attributes; self.class.attributes  end

  protected

  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

6 entries across 6 versions & 2 rubygems

Version Path
nov-smartfm-0.4.1 lib/smartfm/models/base.rb
nov-smartfm-1.0.0 lib/smartfm/models/base.rb
nov-smartfm-1.0.2 lib/smartfm/models/base.rb
smartfm-1.0.1 lib/smartfm/models/base.rb
smartfm-1.0.0 lib/smartfm/models/base.rb
smartfm-1.0.2 lib/smartfm/models/base.rb