easy_orderable 0.1.0 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8a4f7e80bf010be7f63cb3abe11932fb6ed8089
4
- data.tar.gz: 15635b6bcece75b05c0107c2a8004787cab26eed
3
+ metadata.gz: 4eada5c0b4316f63cf8b707fc376491417229fb2
4
+ data.tar.gz: ece2914966aed6814f6738849773e8690b67518d
5
5
  SHA512:
6
- metadata.gz: c4e477d87c2761a4563d957ac2ac9c5cd66747b20b9e4b8ccc4da84727e90f290745452aaa8f3361503f33cc8d3c6847946dce3f2d573a7c7ac3a434d53a3bed
7
- data.tar.gz: 451218c1355be0b9682331f5ae9b641fb53f081918bca309c9357e46da3bc5dfc2d297a026f15b033cf26d388f145ac076ac4fc0f83819eded25b8d90d6939dc
6
+ metadata.gz: 945107acac61f88938172da23935ac44375eeeb24fd856420170434a750143270022fa576e747e5e5886751296869314ad2367ccbe783fd8110525c3c01eab79
7
+ data.tar.gz: 154dbf850ec4445332e5434e3d6c005f82809412e9f3a0bc96260097d46d24be0eb87c2bcc3a604ae84cc172fa991ecb113e9f1faf7c5f8c4de32b6d4951b9b8
@@ -16,7 +16,7 @@ module EasyOrderable
16
16
 
17
17
  def association_names
18
18
  table_names.map do |name|
19
- if custom_association_names && custom_association_names.keys.include?(name.to_sym)
19
+ if custom_association_names && custom_association_names.key?(name.to_sym)
20
20
  custom_association_names[name.to_sym].to_sym
21
21
  else
22
22
  name.to_sym
@@ -5,12 +5,12 @@ module EasyOrderable
5
5
  end
6
6
 
7
7
  def call
8
- args.to_a.map do |e|
9
- if e.first.include?('.')
10
- table_name, column_name = e.first.split('.')
11
- "#{table_name.pluralize}.#{column_name} #{e.second}"
8
+ args.map do |association, direction|
9
+ if association.include?('.')
10
+ table_name, column_name = association.split('.')
11
+ "#{quote(table_name.pluralize)}.#{quote(column_name)} #{direction}"
12
12
  else
13
- "#{e.first} #{e.second}"
13
+ "#{quote(association)} #{direction}"
14
14
  end
15
15
  end
16
16
  end
@@ -18,5 +18,9 @@ module EasyOrderable
18
18
  private
19
19
 
20
20
  attr_reader :args
21
+
22
+ def quote(name)
23
+ ActiveRecord::Base.connection.quote_column_name(name)
24
+ end
21
25
  end
22
26
  end
@@ -1,3 +1,3 @@
1
1
  module EasyOrderable
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.2'
3
3
  end
Binary file
@@ -0,0 +1,80 @@
1
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
3
+ ActiveRecord::InternalMetadata Load (0.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
4
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
5
+  (0.1ms) begin transaction
6
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
7
+  (0.0ms) commit transaction
8
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
9
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
10
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
11
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
12
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
13
+ ActiveRecord::InternalMetadata Load (0.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
14
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
15
+  (0.1ms) begin transaction
16
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
17
+  (0.0ms) commit transaction
18
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
19
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
20
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
21
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
22
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
23
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
24
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
25
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
26
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
27
+  (0.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
28
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
29
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
30
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
31
+  (0.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
32
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
33
+  (0.1ms) DROP TABLE IF EXISTS "bookings"
34
+ ↳ db/schema.rb:15
35
+  (0.2ms) SELECT sqlite_version(*)
36
+ ↳ db/schema.rb:15
37
+  (1.1ms) CREATE TABLE "bookings" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "slots_count" integer, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
38
+ ↳ db/schema.rb:15
39
+  (0.9ms) CREATE INDEX "index_bookings_on_user_id" ON "bookings" ("user_id")
40
+ ↳ db/schema.rb:15
41
+  (0.1ms) DROP TABLE IF EXISTS "requests"
42
+ ↳ db/schema.rb:23
43
+  (0.9ms) CREATE TABLE "requests" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "description" varchar, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
44
+ ↳ db/schema.rb:23
45
+  (0.9ms) CREATE INDEX "index_requests_on_user_id" ON "requests" ("user_id")
46
+ ↳ db/schema.rb:23
47
+  (0.1ms) DROP TABLE IF EXISTS "users"
48
+ ↳ db/schema.rb:31
49
+  (0.9ms) CREATE TABLE "users" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
50
+ ↳ db/schema.rb:31
51
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
52
+ ↳ db/schema.rb:13
53
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
54
+ ↳ db/schema.rb:13
55
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES (20181213104620)
56
+ ↳ db/schema.rb:13
57
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES
58
+ (20181213104543),
59
+ (20181213104420);
60
+
61
+ 
62
+ ↳ db/schema.rb:13
63
+  (1.0ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
64
+ ↳ db/schema.rb:13
65
+ ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
66
+ ↳ db/schema.rb:13
67
+  (0.0ms) begin transaction
68
+ ↳ db/schema.rb:13
69
+ ActiveRecord::InternalMetadata Create (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "development"], ["created_at", "2019-01-21 10:03:34.308090"], ["updated_at", "2019-01-21 10:03:34.308090"]]
70
+ ↳ db/schema.rb:13
71
+  (0.7ms) commit transaction
72
+ ↳ db/schema.rb:13
73
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
74
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
75
+  (0.0ms) begin transaction
76
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
77
+ ActiveRecord::InternalMetadata Update (0.3ms) UPDATE "ar_internal_metadata" SET "value" = ?, "updated_at" = ? WHERE "ar_internal_metadata"."key" = ? [["value", "test"], ["updated_at", "2019-01-21 10:03:34.312471"], ["key", "environment"]]
78
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22
79
+  (0.6ms) commit transaction
80
+ ↳ /Users/filip/.rbenv/versions/2.3.7/bin/rake:22