sakura_gakuin 1.0.7 → 1.1.0
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/sakura_gakuin/angel.rb +2 -3
- data/lib/sakura_gakuin/version.rb +1 -1
- data/lib/sakura_gakuin/yaml_loadable.rb +10 -7
- 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: b4bcdd1043ab40be722ecac6ba4b882824e1cd8c
|
4
|
+
data.tar.gz: 5bea1113e91d39f0e2eca293311206b881ff97b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3c59a836da8e511818edd05e0d31db268df8950ef6a68ed5667381b4059913ef851ecc374262883ca490c77591bc8a547ced5b3155c1716b7a6392e9f9e996d
|
7
|
+
data.tar.gz: 3a6c579fbced84993bc1aa90aa8d25303da52b2e124854b293922b6427c8235af3bc3bf6d0d20edef906e23da4bee7880dced2187c06b661964210ebdeacc714
|
data/lib/sakura_gakuin/angel.rb
CHANGED
@@ -9,9 +9,6 @@ module SakuraGakuin
|
|
9
9
|
@data = []
|
10
10
|
@indexes = {}
|
11
11
|
@index_values = {}
|
12
|
-
|
13
|
-
attr_reader :id
|
14
|
-
create_index(:id, true)
|
15
12
|
end
|
16
13
|
|
17
14
|
module ClassMethods
|
@@ -27,10 +24,16 @@ module SakuraGakuin
|
|
27
24
|
@index_values = {}
|
28
25
|
end
|
29
26
|
|
30
|
-
def primary_key(*keys)
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
def primary_key(key, *keys)
|
28
|
+
keys = ([key] + keys).flatten
|
29
|
+
if keys.length==1 && keys.first==:id
|
30
|
+
attr_reader :id
|
31
|
+
else
|
32
|
+
define_method(:id, ->() {
|
33
|
+
@id ||= keys.map{|k| send(k)}.join("_").downcase.gsub(" ", "_").to_sym
|
34
|
+
})
|
35
|
+
end
|
36
|
+
create_index(:id, true)
|
34
37
|
end
|
35
38
|
|
36
39
|
def create_index(key, uniq=false)
|