activerecord-implicit-order 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d6cc470d51e97071c93222ce4f459ad6e2749f6cd3f1e5b1904984eb15a4b707
4
+ data.tar.gz: 1f5279d9dfff15dbd4b84396788e0186421072a67ab0481b4138ca7c6053f456
5
+ SHA512:
6
+ metadata.gz: 147ebbcaa593d8277680bf47264c60c4226b51111ec0ef7155739d81f857e83513da53b8abc60aa8fdbe8e67613efe52f6d724694c8a5ae0d4de4bbce64def96
7
+ data.tar.gz: 69fc9ca11f54c9a16ff8d5e194503773af4ffafa0991a6db53eb8c358c3c72430a93e76f406606a89c68ce9e758bbef47aa3afb08c83f5f999954ef06ab31361
@@ -0,0 +1,5 @@
1
+ Gemfile.lock
2
+ .ruby-version
3
+ pkg/
4
+ *.gem
5
+ coverage/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 pawurb
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # ActiveRecord UUID Order
2
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,18 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'activerecord-implicit-order/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "activerecord-implicit-order"
8
+ gem.version = ActiveRecordImplicitOrder::VERSION
9
+ gem.authors = ["pawurb"]
10
+ gem.email = ["contact@pawelurbanek.com"]
11
+ gem.summary = %q{ Implicit Order for ActiveRecord }
12
+ gem.description = %q{ Implicit Order for ActiveRecord }
13
+ gem.homepage = "http://github.com/pawurb/activerecord-implicit-order"
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.require_paths = ["lib"]
16
+ gem.license = "MIT"
17
+ gem.add_dependency "activerecord", "< 6.0.0"
18
+ end
@@ -0,0 +1,14 @@
1
+ require 'activerecord-implicit-order/version'
2
+ require 'activerecord-implicit-order/core_extensions'
3
+
4
+ module ActiveRecordImplicitOrder
5
+ def implicit_order_column=(value)
6
+ class_variable_set(:@@implicit_order_column, value)
7
+ end
8
+
9
+ def implicit_order_column
10
+ class_variable_get(:@@implicit_order_column)
11
+ rescue NameError
12
+ class_variable_set(:@@implicit_order_column, nil)
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module ActiveRecord
2
+ module FinderMethods
3
+ def ordered_relation
4
+ if order_values.empty? && (implicit_order_column || primary_key)
5
+ if implicit_order_column && primary_key && implicit_order_column != primary_key
6
+ order(arel_attribute(implicit_order_column).asc, arel_attribute(primary_key).asc)
7
+ else
8
+ order(arel_attribute(implicit_order_column || primary_key).asc)
9
+ end
10
+ else
11
+ self
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveRecordImplicitOrder
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-implicit-order
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - pawurb
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "<"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "<"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.0.0
27
+ description: " Implicit Order for ActiveRecord "
28
+ email:
29
+ - contact@pawelurbanek.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - activerecord-implicit-order.gemspec
40
+ - lib/activerecord-implicit-order.rb
41
+ - lib/activerecord-implicit-order/core_extensions.rb
42
+ - lib/activerecord-implicit-order/version.rb
43
+ homepage: http://github.com/pawurb/activerecord-implicit-order
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 3.0.3
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Implicit Order for ActiveRecord
66
+ test_files: []