Sha256: 2d0af79f2040d56096eed6d7a1dfeec4c890fbe949b8f98570e406d03a30256e

Contents?: true

Size: 490 Bytes

Versions: 2

Compression:

Stored size: 490 Bytes

Contents

require 'active_model/conversion'

module Ripple
  # Provides ActionPack compatibility for {Ripple::Document} models.
  module Conversion
    include ActiveModel::Conversion

    # True if this is a new document
    def new_record?
      new?
    end

    # True if this is not a new document
    def persisted?
      !new?
    end

    # Converts to a view key
    def to_key
      new? ? nil : [key]
    end

    # Converts to a URL parameter
    def to_param
      key
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
seomoz-ripple-1.0.0.pre lib/ripple/conversion.rb
ripple-1.0.0.beta lib/ripple/conversion.rb