0.0
No commit activity in last 3 years
No release in over 3 years
Mongoid Name Type
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.3
~> 4.0.0.beta2
~> 10
 Project Readme

Mongoid Name

Custom serialized type for Mongoid schemas. A string, struct, and array.

require 'mongoid'
require 'mongoid-name'

class User
  include Mongoid::Document
  field :name, type: Mongoid::Name
end

It's an array to encourage autocomplete search. (Index it tho please!)

User.create(name: %w(AJ Ostrow))
user = User.find_by(name: /^ostr/i)

A string for the API and/or views.

user.name
# => "AJ Ostrow"

And a struct for custom messages.

'%s you have 0 stars' % user.name.first
# => "AJ you have 0 stars"

Got middle and last as well. The middle name is always optional (default nil).

user.name = [ 'Gabriel', 'José de la Concordia', 'García Márquez' ]
user.name = [ 'Albert', 'Camus' ]

Notes

Install with bundler.

$ gem install mongoid-name

Please contribute ideas, code, criticism, etc.

License: MIT