Sha256: fc22ac5ef9946b09f20f730c447bca8e44320317cb29da6a9fe8c3d13b957763

Contents?: true

Size: 889 Bytes

Versions: 4

Compression:

Stored size: 889 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Rails
      extend ActiveSupport::Concern

      module InstanceMethods
        def to_param
          id.to_s if persisted?
        end

        def to_model
          self
        end

        def to_key
          [id] if persisted?
        end

        def new_record?
          new?
        end

        def read_attribute(name)
          self[name]
        end

        def read_attribute_before_type_cast(name)
          read_key_before_type_cast(name)
        end

        def write_attribute(name, value)
          self[name] = value
        end
      end

      module ClassMethods
        def has_one(*args)
          one(*args)
        end

        def has_many(*args, &extension)
          many(*args, &extension)
        end

        def column_names
          keys.keys
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongo_mapper-0.10.1 lib/mongo_mapper/plugins/rails.rb
mongo_mapper-0.10.0 lib/mongo_mapper/plugins/rails.rb
mongo_mapper-0.9.2 lib/mongo_mapper/plugins/rails.rb
mongo_mapper-0.9.1 lib/mongo_mapper/plugins/rails.rb