Module: Elastics::ClassProxy::ActiveModel
- Defined in:
- lib/elastics/class_proxy/active_model.rb
Instance Method Summary collapse
-
#add_callbacks ⇒ Object
overrides the ModelSyncer#add_callbacks.
- #default_mapping ⇒ Object
- #init(*vars) ⇒ Object
Instance Method Details
#add_callbacks ⇒ Object
overrides the ModelSyncer#add_callbacks
29 30 31 |
# File 'lib/elastics/class_proxy/active_model.rb', line 29 def add_callbacks # no callbacks to add, since it calls elastics.sync on save and destroy end |
#default_mapping ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/elastics/class_proxy/active_model.rb', line 9 def default_mapping props = { } context.attributes.each do |name, attr| = attr.send(:options) props[name] = case when .has_key?(:properties) Utils.keyfy(:to_s, attr.send(:options)[:properties]) when .has_key?(:not_analyzed) && [:not_analyzed] || .has_key?(:analyzed) && ![:analyzed] { 'type' => 'string', 'index' => 'not_analyzed' } when [:type] == DateTime { 'type' => 'date', 'format' => 'dateOptionalTime' } else next end end props.empty? ? super : super.deep_merge(index => {'mappings' => {type => {'properties' => props}}}) end |
#init(*vars) ⇒ Object
5 6 7 |
# File 'lib/elastics/class_proxy/active_model.rb', line 5 def init(*vars) variables.deep_merge! *vars end |