Sha256: 801bfaf47bed6d6926f81ef7540779dc9131ed6d3d11524a85c88ed7cc345c24

Contents?: true

Size: 525 Bytes

Versions: 3

Compression:

Stored size: 525 Bytes

Contents

require 'active_model/conversion'

module Ripple
  # Provides ActionPack compatibility for {Ripple::Document} models.
  module Conversion
    extend  ActiveSupport::Concern
    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

3 entries across 3 versions & 3 rubygems

Version Path
wyngle-ripple-0.1.0 lib/ripple/conversion.rb
better-ripple-1.0.0 lib/ripple/conversion.rb
ripple-1.0.0.beta2 lib/ripple/conversion.rb