status_tag 0.1.3 → 0.2.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/status_tag/presenter.rb +10 -8
- data/lib/status_tag/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: ea164cee0e501e85a8cb38bc899b7e7e2579e560
|
4
|
+
data.tar.gz: ad09d9846f29418ebb8e01f3a228945da3bae720
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7d3cb297e76556e6f572f04f5e799f9aecffa77405a07de184544b3d57be3068cfafd0dcb0817080e85fdcaf53b688928ccc21ca486b88aef3843ee1dbe164c
|
7
|
+
data.tar.gz: 3352cb683f641bce5da05e1c853ae0a9d9a56846ec7e6ee6f11c4f0b877417da9cc96fb7dfc548cd04c275153f124eb94b90eab26a5b9f0a4ab7c1522c3cbe00
|
data/lib/status_tag/presenter.rb
CHANGED
@@ -17,12 +17,14 @@ module StatusTag
|
|
17
17
|
# Override constants in subclasses
|
18
18
|
ORDERED_CHOICES = [StatusTag::Choice.new]
|
19
19
|
CSS_CLASS = [] # A CSS class or classes to assign to all tags generated with the presenter
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
|
21
|
+
# RECEIVER CONFIGURATION
|
22
|
+
# :object sends the messages to the object passed into the initializer
|
23
|
+
# :self sends the messages to the to the presenter class instance
|
24
|
+
# (which has an internal reference to object) and would allow more complicated logic that
|
25
|
+
# pertains to the view, not the model.
|
26
|
+
CHOICE_NAME_MESSAGE_RECEIVER = :object
|
27
|
+
CHOICE_TEXT_MESSAGE_RECEIVER = :object
|
26
28
|
|
27
29
|
attr_accessor :object, # e.g. an instance of the User class
|
28
30
|
:aspect # e.g. "state", "status" or some other descriptive name for this particular status tag
|
@@ -38,7 +40,7 @@ module StatusTag
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def decide
|
41
|
-
@choice = if (self.class)::
|
43
|
+
@choice = if (self.class)::CHOICE_NAME_MESSAGE_RECEIVER == :object
|
42
44
|
decider.decide(object)
|
43
45
|
else
|
44
46
|
decider.decide(self)
|
@@ -48,7 +50,7 @@ module StatusTag
|
|
48
50
|
def text
|
49
51
|
return "" unless choice
|
50
52
|
if choice.text.is_a?(Symbol)
|
51
|
-
receiver = (self.class)::
|
53
|
+
receiver = (self.class)::CHOICE_TEXT_MESSAGE_RECEIVER == :object ? object : self
|
52
54
|
receiver.send(choice.text)
|
53
55
|
else
|
54
56
|
choice.text
|
data/lib/status_tag/version.rb
CHANGED