tachyon 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tachyon.rb +0 -22
- data/lib/tachyon/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7882de4f67436fff7b522c0be26a0b49689bcd5e
|
4
|
+
data.tar.gz: 92c62b8cebbff5a64a1debed2c43297536fd5890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c634d8836430187401b0e4ccf895c907169f7928a75e55fddf781a82fc9d4a14cc08fd2f113a791eb4d0babd1ed40942c93d6df054fb6e465d168ec688c80b3
|
7
|
+
data.tar.gz: 7e4fa020dc44fb6e4a0259000220c95712b6c6dd8c5a34717b380a7508dca82cf2a5fef06ed147a4e3ad39403ef47f63c8c8cee750f286ebd88eb44a48717d44
|
data/lib/tachyon.rb
CHANGED
@@ -13,30 +13,8 @@ class Tachyon
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.insert_record(klass, data)
|
16
|
-
if klass.has_attribute?(:created_at) && klass.has_attribute?(:updated_at)
|
17
|
-
defaults = { created_at: Time.now, updated_at: Time.now }.with_indifferent_access
|
18
|
-
data = defaults.merge(data.with_indifferent_access)
|
19
|
-
end
|
20
|
-
|
21
|
-
table = klass.arel_table
|
22
|
-
mapped_data = data.map do |key, value|
|
23
|
-
[table[key], value]
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
insert = Arel::InsertManager.new
|
28
|
-
insert.into(table)
|
29
|
-
insert.insert(mapped_data)
|
30
|
-
|
31
16
|
begin
|
32
|
-
begin
|
33
|
-
klass.connection.execute(insert.to_sql)
|
34
|
-
rescue ArgumentError
|
35
|
-
# If we can't generate the insert using Arel (likely because
|
36
|
-
# of an issue with a serialized attribute) then fall back
|
37
|
-
# to safe but slow behaviour.
|
38
17
|
klass.new(data).save(validate: false)
|
39
|
-
end
|
40
18
|
rescue ActiveRecord::RecordNotUnique
|
41
19
|
end
|
42
20
|
end
|
data/lib/tachyon/version.rb
CHANGED