sraas 0.3.12 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7a3ad73f1a4ad628230d4addbb03c7dec6a7027
4
- data.tar.gz: 4c81e9fad986e988682ddebfd43736972aa06e69
3
+ metadata.gz: 6eaee146f11038edc1963d62b9854dc350d11c20
4
+ data.tar.gz: c04e697ce2763e8538b4352105a41dbd165857a8
5
5
  SHA512:
6
- metadata.gz: 39ce34ca169dc863fa821432ca3370701a8b02be7ac53841e5fa347ce6105548dcaf6b01f3d243f62afb082e8a7c829682cc25af5ef98bd9442cb4bd3c6b01e6
7
- data.tar.gz: fe0003b30d5a6e6aaa699031ebfc4e01a45856ed13dd8f27ed810cf809ee1ac6c54b5c9d754dcc1e4d1305c15315ba8f2c0789ae94c45cb2447d36f8cf33acc5
6
+ metadata.gz: 1da68d467c235c11bd320f64a95d87b1596916e654a11bb22f34ac71aa44c77435fbc1909176b39206381cf3492a3d42c64c57e69d3b3745c15e424ef2646b6a
7
+ data.tar.gz: 6ffd9cfaeb5390e086e3f5befc4345b83f9e8c27facdd47b5ba4de19dda7540f4702ca621e607cbf568ad95d3c49809b3e6b9b05850319c5d80d335085c0cb9b
@@ -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
- puts "[DEPRECATION WARNING] Since GEM 0.3.0, semantics changed for has_sraas. You probably want to say has_sraas name: ..."
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
@@ -1,3 +1,3 @@
1
1
  module Sraas
2
- VERSION = '0.3.12'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sraas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel