Sha256: 86117de9bce1972fd4d4d63c20b413ba08ece67c2683ba2cc2c8398ca174b8cd
Contents?: true
Size: 561 Bytes
Versions: 1
Compression:
Stored size: 561 Bytes
Contents
class MemoryDictionary::Dictionary include Mongoid::Document field :name, type: String embeds_many :words, class_name: 'MemoryDictionary::Word' validates :name, uniqueness: true index({ name: 1 }, { unique: true, name: 'dictionary_names_index' }) #index 'words.name' => 1 def translations words.map(&:translation).uniq end def words_by_translation(translation) words.where(translation: translation) end def append_word(name, translation) words << MemoryDictionary::Word.new(name: name, translation: translation) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
memory_dictionary-1.0.0 | lib/memory_dictionary/dictionary.rb |