Sha256: 4a4db00e2c3e43d93e34f782d0bc15d00df01f7377b1bb83229bd81e188d641c
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
module Neoid class ModelConfig attr_reader :properties attr_reader :search_options attr_reader :relationship_options def initialize(klass) @klass = klass end def stored_fields @stored_fields ||= {} end def field(name, &block) self.stored_fields[name] = block end def relationship(options) @relationship_options = options end def search(&block) raise "search needs a block" unless block_given? @search_options = SearchConfig.new block.(@search_options) end def inspect "#<Neoid::ModelConfig @properties=#{properties.inspect} @search_options=#{@search_options.inspect}>" end end class SearchConfig def index_fields @index_fields ||= {} end def fulltext_fields @fulltext_fields ||= {} end def index(field, options = {}, &block) index_fields[field] = options.merge(block: block) end def fulltext(field, options = {}, &block) fulltext_fields[field] = options.merge(block: block) end def inspect "#<Neoid::SearchConfig @index_fields=#{index_fields.inspect} @fulltext_fields=#{fulltext_fields.inspect}>" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
neoid-0.0.51 | lib/neoid/model_config.rb |
neoid-0.0.5.alpha | lib/neoid/model_config.rb |