familia 2.0.0.pre3 → 2.0.0.pre4
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/Gemfile.lock +1 -1
- data/lib/familia/horreum/class_methods.rb +14 -0
- data/lib/familia/version.rb +1 -1
- data/try/horreum/class_methods_try.rb +27 -36
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c17c7c0fbd21ec7edf380a157f36bcf50632838c083474ac56291653e5e5b5f2
|
4
|
+
data.tar.gz: 496226f45b28c48a20f4a7c0901e45f048407b53cb80d4d373f5840f06673bd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfce15edc52796648eb1356be796260d8e8dae8bcba38f11a435b86cd732f73acacc8959e67d2bb3e3025d82a962e63ca2627fecb2f88dfc0e76bb1da174592d
|
7
|
+
data.tar.gz: 3cc196dc11aaf65409061ed5772043c151dfbc0fe39701b86e2808d2c9f1a55a5647f9ba22cb80cc806752ad17d41a05c2cce743fecf2258e8ff6b91f9868c12
|
data/Gemfile.lock
CHANGED
@@ -237,6 +237,20 @@ module Familia
|
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
240
|
+
# Converts the class name into a string that can be used to look up
|
241
|
+
# configuration values. This is particularly useful when mapping
|
242
|
+
# familia models with specific database numbers in the configuration.
|
243
|
+
#
|
244
|
+
# @example V2::Session.config_name => 'session'
|
245
|
+
#
|
246
|
+
# @return [String] The underscored class name as a string
|
247
|
+
def config_name
|
248
|
+
name.split('::').last
|
249
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
250
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
251
|
+
.downcase
|
252
|
+
end
|
253
|
+
|
240
254
|
# Creates and persists a new instance of the class.
|
241
255
|
#
|
242
256
|
# @param *args [Array] Variable number of positional arguments to be passed
|
data/lib/familia/version.rb
CHANGED
@@ -1,47 +1,38 @@
|
|
1
|
+
# try/horreum/class_methods_try.rb
|
2
|
+
|
1
3
|
# Test Horreum class methods
|
2
4
|
|
3
5
|
require_relative '../helpers/test_helpers'
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
field :name
|
11
|
-
field :age
|
12
|
-
end
|
13
|
-
|
14
|
-
result = user_class.respond_to?(:create) && user_class.respond_to?(:exists?)
|
15
|
-
result
|
16
|
-
rescue StandardError => e
|
17
|
-
false
|
7
|
+
TestUser = Class.new(Familia::Horreum) do
|
8
|
+
identifier_field :email
|
9
|
+
field :email
|
10
|
+
field :name
|
11
|
+
field :age
|
18
12
|
end
|
19
|
-
#=> true
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
user_class = Class.new(Familia::Horreum) do
|
24
|
-
identifier_field :email
|
25
|
-
field :email
|
26
|
-
field :name
|
14
|
+
module AnotherModuleName
|
15
|
+
AnotherTestUser = Class.new(Familia::Horreum) do
|
27
16
|
end
|
28
|
-
|
29
|
-
user_class.respond_to?(:multiget)
|
30
|
-
rescue StandardError => e
|
31
|
-
false
|
32
17
|
end
|
33
|
-
|
18
|
+
|
19
|
+
## create factory method with existence checking
|
20
|
+
TestUser
|
21
|
+
#==> _.respond_to?(:create)
|
22
|
+
#==> _.respond_to?(:exists?)
|
23
|
+
|
24
|
+
## multiget method is available
|
25
|
+
TestUser
|
26
|
+
#==> _.respond_to?(:multiget)
|
34
27
|
|
35
28
|
## find_keys method is available
|
36
|
-
|
37
|
-
|
38
|
-
identifier_field :email
|
39
|
-
field :email
|
40
|
-
field :name
|
41
|
-
end
|
29
|
+
TestUser
|
30
|
+
#==> _.respond_to?(:find_keys)
|
42
31
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
32
|
+
## config name turns a top-level class into a symbol
|
33
|
+
TestUser.config_name.to_sym
|
34
|
+
#=> :test_user
|
35
|
+
|
36
|
+
## config name turns the fully qualified class into a symbol, but just the right most class
|
37
|
+
AnotherModuleName::AnotherTestUser.config_name.to_sym
|
38
|
+
#=> :another_test_user
|