Sha256: cc2bc48673687430507cb9a0a944805d0360101b572630e4473c592daf562e55

Contents?: true

Size: 413 Bytes

Versions: 5

Compression:

Stored size: 413 Bytes

Contents

module NinjaModel
  class Base
    class_inheritable_accessor :primary_key
    self.primary_key = :id
    undef_method(:id) if method_defined?(:id)
  end

  module Identity
    def to_model
      self
    end

    def to_param
      send(self.class.primary_key).to_s if persisted?
    end

    def to_key
      key = nil
      key = send(self.class.primary_key) if persisted?
      [key] if key
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ninja-model-0.6.2 lib/ninja_model/identity.rb
ninja-model-0.6.1 lib/ninja_model/identity.rb
ninja-model-0.6.0 lib/ninja_model/identity.rb
ninja-model-0.5.7 lib/ninja_model/identity.rb
ninja-model-0.5.6 lib/ninja_model/identity.rb