module Flex::ClassProxy::ActiveModel

Public Instance Methods

add_callbacks() click to toggle source

overrides the ModelSyncer#add_callbacks

# File lib/flex/class_proxy/active_model.rb, line 29
def add_callbacks
  # no callbacks to add, since it calls flex.sync on save and destroy
end
default_mapping() click to toggle source
Calls superclass method
# File lib/flex/class_proxy/active_model.rb, line 9
def default_mapping
  props = { }
  context.attributes.each do |name, attr|
    options     = attr.send(:options)
    props[name] = case
                  when options.has_key?(:properties)
                    Utils.keyfy(:to_s, attr.send(:options)[:properties])
                  when options.has_key?(:not_analyzed) && options[:not_analyzed] ||
                       options.has_key?(:analyzed)     && !options[:analyzed]
                    { 'type' => 'string', 'index' => 'not_analyzed' }
                  when options[:type] == DateTime
                    { 'type' => 'date', 'format' => 'dateOptionalTime' }
                  else
                    next
                  end
  end
  props.empty? ? super :  super.deep_merge(index => {'mappings' => {type => {'properties' => props}}})
end
init(*vars) click to toggle source
# File lib/flex/class_proxy/active_model.rb, line 5
def init(*vars)
  variables.deep_merge! *vars
end