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
- #_t_serialize_id_for_sql(id) ⇒ Object
- #_t_serialize_ids(ids, association = nil) ⇒ Object
- #id_class_for(association) ⇒ Object
Instance Method Details
#_t_serialize_id_for_sql(id) ⇒ Object
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 |
#_t_serialize_ids(ids, association = nil) ⇒ Object
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 |
#id_class_for(association) ⇒ Object
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 |