order_by 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4ca01ef61ed585beea17fe8431de410136b23248dacf43b9d797973807eefb94
4
+ data.tar.gz: 4d09278def0fa0a7fbcaa5a7bf7d1ab7c8e392cd53f30d48ffc10a2526c1f117
5
+ SHA512:
6
+ metadata.gz: 6872c8caeb70eba82e0ee4265b60d2aff027c5c5478fca52879c3080f10dd015906112f4a5ef9e12c236f282cb2857dccc19ac47320b9e8896523ce7fc29bf10
7
+ data.tar.gz: d2703109bea7a835bdc937f0107887eb9dfb52ed43e26a16b445f11a04faf1c4c4e7ddafe6a6393e8d4d0cf8320c3d4cf5da9cdda6620c843c9adc82947ff96f
@@ -0,0 +1,3 @@
1
+ module OrderBy
2
+ VERSION = '0.0.2'
3
+ end
data/lib/order_by.rb ADDED
@@ -0,0 +1,14 @@
1
+ module Orderable
2
+ extend ActiveSupport::Concern
3
+
4
+ module ClassMethods
5
+ # @param column [String]
6
+ # @param direction [String] ASC | DESC
7
+ # @param nulls [String] NULLS FIRST | NULLS LAST
8
+ # @return [ActiveRecord::Relation] ordered active record relation
9
+ def order_by(column, direction = nil, nulls = nil)
10
+ sort_string = [column.underscore, direction.upcase, nulls.upcase].reject(&:blank?).join(' ')
11
+ order(Arel.sql(sort_string))
12
+ end
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: order_by
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Ian Heraty
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/order_by.rb
20
+ - lib/order_by/version.rb
21
+ homepage:
22
+ licenses:
23
+ - MIT
24
+ metadata:
25
+ source_code_uri: https://github.com/BigGreenCompany/order_by
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.6.0
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubygems_version: 3.2.3
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Adds order functionality to your ActiveRecord models so that your controllers
45
+ have shared interface for accepting column/direction params.
46
+ test_files: []