organizer-rails 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/models/concerns/organizer/identifiable.rb +17 -13
- data/lib/organizer/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 145be80c0dc4c6b9c012b474c6958d8891aa81143c39cdff4749d5713de2ad02
|
4
|
+
data.tar.gz: 3b83640f157bc0980e2d8867a32a08e71e407adc332912b3ed49d0e72317dd34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e363e498d9d7ce66a643e90e9021371faeba2eccbeb3ee48d4df10906d641ccc0ffcde22f6287949893f1b9dc258c220e01818ab36a11ccc5f7b03aa6839227
|
7
|
+
data.tar.gz: 96c82bafd31b4132f8cf0ec2032064302889781a48232c9d60644d061ebffdbbc8090fe95f78cbfce7ffe551dab4755f3c7985549a862fe59eccfc8631608cc0
|
data/README.md
CHANGED
@@ -1,15 +1,24 @@
|
|
1
|
+
require 'memery'
|
2
|
+
|
1
3
|
module Organizer
|
2
4
|
concern :Identifiable do
|
3
5
|
class << self
|
4
|
-
def by column_name
|
6
|
+
def by column_name, symbolized: false
|
5
7
|
dup.tap do
|
6
8
|
_1.module_eval do
|
7
9
|
included do
|
8
10
|
@identified_by = column_name
|
11
|
+
@symbolize_ids = symbolized
|
9
12
|
end
|
10
13
|
|
11
14
|
class_methods do # public API
|
12
|
-
define_method
|
15
|
+
define_method column_name.to_s.pluralize do
|
16
|
+
if @symbolize_ids
|
17
|
+
identifiers.map &:to_sym
|
18
|
+
else
|
19
|
+
identifiers
|
20
|
+
end
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
15
24
|
end
|
@@ -17,29 +26,24 @@ module Organizer
|
|
17
26
|
end
|
18
27
|
|
19
28
|
class_methods do
|
29
|
+
include Memery
|
30
|
+
|
20
31
|
def [] *id
|
21
32
|
return id.map { self[_1] } if id.many?
|
22
33
|
|
23
34
|
case id = id.first
|
24
35
|
when Enumerable
|
25
|
-
|
36
|
+
where @identified_by => id
|
26
37
|
else
|
27
|
-
|
38
|
+
find_by @identified_by => id or
|
28
39
|
raise ArgumentError, "Couldn't find #{self} `#{id}`"
|
29
40
|
end
|
30
41
|
end
|
31
42
|
|
32
43
|
private
|
33
44
|
|
34
|
-
def identifiers
|
35
|
-
@
|
36
|
-
all.pluck(@identified_by)
|
37
|
-
.map &:to_sym
|
38
|
-
end
|
39
|
-
|
40
|
-
def identified_as identifier
|
41
|
-
(@identified ||= {}.with_indifferent_access)[identifier] ||= # cache
|
42
|
-
find_by @identified_by => identifier
|
45
|
+
memoize def identifiers
|
46
|
+
all.pluck(@identified_by)
|
43
47
|
end
|
44
48
|
end
|
45
49
|
end
|
data/lib/organizer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: organizer-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Senko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '7.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: memery
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Use lists, tags, flags, etc. to organize your application records.
|
28
42
|
email:
|
29
43
|
- Alexander.Senko@gmail.com
|
@@ -58,7 +72,7 @@ licenses:
|
|
58
72
|
metadata:
|
59
73
|
homepage_uri: https://github.com/Alexander-Senko/organizer
|
60
74
|
source_code_uri: https://github.com/Alexander-Senko/organizer
|
61
|
-
changelog_uri: https://github.com/Alexander-Senko/organizer/blob/v0.
|
75
|
+
changelog_uri: https://github.com/Alexander-Senko/organizer/blob/v0.2.0/CHANGELOG.md
|
62
76
|
post_install_message:
|
63
77
|
rdoc_options: []
|
64
78
|
require_paths:
|
@@ -74,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
requirements: []
|
77
|
-
rubygems_version: 3.5.
|
91
|
+
rubygems_version: 3.5.5
|
78
92
|
signing_key:
|
79
93
|
specification_version: 4
|
80
94
|
summary: Record organizer for Rails
|