Module: Tenacity::OrmExt::Sequel::ClassMethods
- Includes:
- Helpers
- Defined in:
- lib/tenacity/orm_ext/sequel.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Helpers
#_t_serialize_id_for_sql, #_t_serialize_ids, #id_class_for
Instance Attribute Details
#_t_belongs_to_associations ⇒ Object
Returns the value of attribute _t_belongs_to_associations.
55
56
57
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 55
def _t_belongs_to_associations
@_t_belongs_to_associations
end
|
#_t_has_many_associations ⇒ Object
Returns the value of attribute _t_has_many_associations.
54
55
56
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 54
def _t_has_many_associations
@_t_has_many_associations
end
|
#_t_has_one_associations ⇒ Object
Returns the value of attribute _t_has_one_associations.
53
54
55
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 53
def _t_has_one_associations
@_t_has_one_associations
end
|
Instance Method Details
#_t_delete(ids, run_callbacks = true) ⇒ Object
105
106
107
108
109
110
111
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 105
def _t_delete(ids, run_callbacks=true)
if run_callbacks
filter(:id => _t_serialize_ids(ids)).destroy
else
filter(:id => _t_serialize_ids(ids)).delete
end
end
|
#_t_find(id) ⇒ Object
65
66
67
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 65
def _t_find(id)
self[_t_serialize(id)]
end
|
#_t_find_all_by_associate(property, id) ⇒ Object
78
79
80
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 78
def _t_find_all_by_associate(property, id)
filter(property.to_sym => _t_serialize(id)).to_a
end
|
#_t_find_all_ids_by_associate(property, id) ⇒ Object
82
83
84
85
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 82
def _t_find_all_ids_by_associate(property, id)
results = db["SELECT id FROM #{table_name} WHERE #{property} = #{_t_serialize_id_for_sql(id)}"].all
results.map { |r| r[:id] }
end
|
#_t_find_bulk(ids) ⇒ Object
69
70
71
72
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 69
def _t_find_bulk(ids)
return [] if ids.nil? || ids.empty?
filter(:id => _t_serialize_ids(ids)).to_a
end
|
#_t_find_first_by_associate(property, id) ⇒ Object
74
75
76
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 74
def _t_find_first_by_associate(property, id)
first(property.to_sym => _t_serialize(id))
end
|
#_t_id_type ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 57
def _t_id_type
@_t_id_type_clazz ||= begin
Kernel.const_get(db_schema.values.find{ |x| x[:primary_key] == true }[:type].to_s.capitalize)
rescue
Integer
end
end
|
#_t_initialize_belongs_to_association(association) ⇒ Object
100
101
102
103
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 100
def _t_initialize_belongs_to_association(association)
@_t_belongs_to_associations ||= []
@_t_belongs_to_associations << association
end
|
#_t_initialize_has_many_association(association) ⇒ Object
95
96
97
98
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 95
def _t_initialize_has_many_association(association)
@_t_has_many_associations ||= []
@_t_has_many_associations << association
end
|
#_t_initialize_has_one_association(association) ⇒ Object
90
91
92
93
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 90
def _t_initialize_has_one_association(association)
@_t_has_one_associations ||= []
@_t_has_one_associations << association
end
|
#_t_initialize_tenacity ⇒ Object
87
88
|
# File 'lib/tenacity/orm_ext/sequel.rb', line 87
def _t_initialize_tenacity
end
|