Sha256: 80acc4fc717b08f530177a951e00ae95d9aa0587ffbbcc75fb150e926d96b9d7

Contents?: true

Size: 917 Bytes

Versions: 6

Compression:

Stored size: 917 Bytes

Contents

module MongoMapper
  module Plugins
    module Rails
      def self.configure(model)
        model.extend ActiveModel::Naming if defined?(ActiveModel)
      end

      module InstanceMethods
        def to_param
          id.to_s
        end

        def to_model
          self
        end

        def new_record?
          new?
        end

        def read_attribute(name)
          self[name]
        end

        def read_attribute_before_typecast(name)
          read_key_before_typecast(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)
          many(*args)
        end

        def column_names
          keys.keys
        end

        def human_name
          self.name.demodulize.titleize
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
numon-0.0.1 lib/mongo_mapper/plugins/rails.rb
mongo_mapper-0.7.1 lib/mongo_mapper/plugins/rails.rb
mongo_mapper-unstable-2010.3.8 lib/mongo_mapper/plugins/rails.rb
mongo_mapper-unstable-2010.3.5 lib/mongo_mapper/plugins/rails.rb
mongo_mapper-unstable-2010.3.4 lib/mongo_mapper/plugins/rails.rb
mongo_mapper-unstable-2010.3.3 lib/mongo_mapper/plugins/rails.rb