Module: Tenacity::OrmExt::Helpers

Included in:
ActiveRecord::ClassMethods, ActiveRecord::InstanceMethods, CouchRest::ClassMethods, DataMapper::ClassMethods, DataMapper::InstanceMethods, MongoMapper::ClassMethods, Mongoid::ClassMethods, Ripple::ClassMethods, Sequel::ClassMethods, Sequel::InstanceMethods, Toystore::ClassMethods
Defined in:
lib/tenacity/orm_ext/helpers.rb

Overview

:nodoc:

Instance Method Summary (collapse)

Instance Method Details

- (Object) _t_serialize_id_for_sql(id)



23
24
25
26
27
28
29
30
31
32
# File 'lib/tenacity/orm_ext/helpers.rb', line 23

def _t_serialize_id_for_sql(id)
  return id if id.nil?

  serialized_id = _t_serialize(id)
  if serialized_id.class == String
    "'#{serialized_id}'"
  else
    serialized_id
  end
end

- (Object) _t_serialize_ids(ids, association = nil)



15
16
17
18
19
20
21
# File 'lib/tenacity/orm_ext/helpers.rb', line 15

def _t_serialize_ids(ids, association=nil)
  if ids.respond_to?(:map)
    ids.map { |id| _t_serialize(id, association) }
  else
    _t_serialize(ids, association)
  end
end

- (Object) id_class_for(association)



5
6
7
8
9
10
11
12
13
# File 'lib/tenacity/orm_ext/helpers.rb', line 5

def id_class_for(association)
  if association.polymorphic?
    String
  elsif association.type == :t_belongs_to
    association.associate_class._t_id_type
  else
    raise "Unable to determine id class for type: #{association.type}, source: #{association.source}, target: #{association.associate_class}"
  end
end