action_command 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/action_command/utils.rb +10 -0
- data/lib/action_command/version.rb +1 -1
- 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: 3ac741bfd947eab14a520ca140441c04e88bb93a
|
4
|
+
data.tar.gz: cd8e7c5f4f993c3072a74e9a7d7660c71cdaa129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08d0f084fe0ae9c451ae3a119fbf54f5712b6bf6187a05c02aa69455950e9a9b11639200c3e99b3a8120009b96e529188e388af69bf4414a1ab3504a0bcbcd56
|
7
|
+
data.tar.gz: 3f7475cc8e7c25ee6cd9b74b8c681b453e370aaaafa5c1fe9b517b36b0575eb9b9948e044df91fe5eb453a6a26e49d78e925c531b179d912235b4371b1e4d072
|
data/Gemfile.lock
CHANGED
data/lib/action_command/utils.rb
CHANGED
@@ -15,6 +15,16 @@ module ActionCommand
|
|
15
15
|
return cls.find(item) if item.is_a? Integer
|
16
16
|
return yield(item)
|
17
17
|
end
|
18
|
+
|
19
|
+
# Used for cases where you might have a active record object, or an integer
|
20
|
+
# id, or some kind of string identifier. If it is an active record object,
|
21
|
+
# this will return its id. If it is an integer, it will return it. Otherwise,
|
22
|
+
# it will pass the string to yield, which can lookup the object
|
23
|
+
def self.find_id(cls, item)
|
24
|
+
return item.id if item.is_a? cls
|
25
|
+
return item if item.is_a? Integer
|
26
|
+
return yield(item)
|
27
|
+
end
|
18
28
|
end
|
19
29
|
|
20
30
|
end
|