sraas 0.3.12 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sraas/has_sraas.rb +15 -3
- data/lib/sraas/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: 6eaee146f11038edc1963d62b9854dc350d11c20
|
4
|
+
data.tar.gz: c04e697ce2763e8538b4352105a41dbd165857a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1da68d467c235c11bd320f64a95d87b1596916e654a11bb22f34ac71aa44c77435fbc1909176b39206381cf3492a3d42c64c57e69d3b3745c15e424ef2646b6a
|
7
|
+
data.tar.gz: 6ffd9cfaeb5390e086e3f5befc4345b83f9e8c27facdd47b5ba4de19dda7540f4702ca621e607cbf568ad95d3c49809b3e6b9b05850319c5d80d335085c0cb9b
|
data/lib/sraas/has_sraas.rb
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
module Sraas
|
2
2
|
module HasSraas
|
3
3
|
module ClassMethods
|
4
|
+
# name: string -- the name of the deck to use with Sraas
|
5
|
+
# symbol -- the method to call on this object that returns a deck name
|
6
|
+
# nil -- use the default in configuration or errors...
|
7
|
+
# fingerprint: string -- allows locking to one specific deck version
|
4
8
|
def has_sraas(name: nil, fingerprint: nil, deck: nil)
|
5
9
|
if deck # v1.0 Syntax
|
6
|
-
|
7
|
-
name ||= deck # Be nice for now...
|
10
|
+
raise "Since GEM 0.3.0, semantics changed for has_sraas. You need to say has_sraas name: ..."
|
8
11
|
end
|
9
12
|
has_one :sraas, as: :sraas_consumerable, class_name: 'Sraas::Consumer'
|
10
13
|
|
11
14
|
after_create :configure_sraas_consumer!
|
12
15
|
|
16
|
+
if name.is_a?(Symbol)
|
17
|
+
# We allow specifying a symbol as a method name/attribute that will return the deck name
|
18
|
+
# make sure model supports it:
|
19
|
+
raise "[Undefined Method Error] Class '#{self.name}' doesn't have a method #{name}" unless self.method_defined?(name) || self.has_attribute?(name)
|
20
|
+
end
|
13
21
|
self.sraas_default_deck_name = name || Sraas.configuration.default_deck_name
|
14
22
|
self.sraas_default_deck_fingerprint = fingerprint || Sraas.configuration.default_deck_fingerprint
|
15
23
|
end
|
@@ -48,7 +56,11 @@ module Sraas
|
|
48
56
|
end
|
49
57
|
|
50
58
|
def specified_deck_name
|
51
|
-
self.class.sraas_default_deck_name
|
59
|
+
if self.class.sraas_default_deck_name.is_a?(Symbol)
|
60
|
+
self.send(self.class.sraas_default_deck_name)
|
61
|
+
else
|
62
|
+
self.class.sraas_default_deck_name
|
63
|
+
end
|
52
64
|
end
|
53
65
|
|
54
66
|
def specified_deck_fingerprint
|
data/lib/sraas/version.rb
CHANGED