Class: ActiveStash::SchemaBuilder
- Inherits:
-
Object
- Object
- ActiveStash::SchemaBuilder
- Defined in:
- lib/active_stash/schema_builder.rb
Instance Method Summary collapse
-
#build ⇒ Object
Builds a schema object for the model.
-
#initialize(model_class) ⇒ SchemaBuilder
constructor
A new instance of SchemaBuilder.
Constructor Details
#initialize(model_class) ⇒ SchemaBuilder
Returns a new instance of SchemaBuilder.
3 4 5 |
# File 'lib/active_stash/schema_builder.rb', line 3 def initialize(model_class) @model_class = model_class end |
Instance Method Details
#build ⇒ Object
Builds a schema object for the model
## Types
-
`:boolean` map to “exact” indexes
-
`“timestamp`, `:date`, `:datetime` and all numeric types map to ”range“ indexes
-
`:string` and `text` types map to exact indexes but also have “match” indexes
created with a “_match” suffix (e.g. “email_match”)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/active_stash/schema_builder.rb', line 16 def build indexes = @model_class.stash_indexes.indexes.each_with_object({}) do |index, acc| case index.type when :exact exact_index(acc, index) when :match match_index(acc, index) when :range range_index(acc, index) when :dynamic_match dynamic_match(acc, index) end end {"indexes" => indexes, "type" => stash_type} end |