status_tag 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/status_tag/presenter.rb +3 -2
- data/lib/status_tag/version.rb +1 -1
- data/lib/status_tag.rb +6 -6
- 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: 50db7516df1a9992517cc1617e0a73e084166854
|
4
|
+
data.tar.gz: 92381fed4bb48a184477dc559e976a58f7db68aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e5748ea0f37e90cae1ce69a462b159bb121e84a18ee33afd966a9982df1bcd8c7b1a01f16c8204bd0910d77b14d79acd2646633744af69b6c7b0dbccaf25c4b
|
7
|
+
data.tar.gz: 53b452d3f382b2400f18d30c442bb895048bf03ec625659033ce65d48d06a632cbf173d35439ecce9af1eabcc9f7ea243127794a3de1c03d02e0e7fc624da1cd
|
data/lib/status_tag/presenter.rb
CHANGED
@@ -28,12 +28,13 @@ module StatusTag
|
|
28
28
|
:aspect # e.g. "state", "status" or some other descriptive name for this particular status tag
|
29
29
|
# Defaults to nil, so by default there is only one StatusTag presenter allowed per object class,
|
30
30
|
# as the aspect provides a namespace for additional presenters.
|
31
|
-
attr_reader :decider, :choice
|
31
|
+
attr_reader :decider, :choice, :options
|
32
32
|
|
33
|
-
def initialize(object:, aspect: nil)
|
33
|
+
def initialize(object:, aspect: nil, options: {})
|
34
34
|
@object = object
|
35
35
|
@aspect = aspect
|
36
36
|
@decider = StatusTag::Decider.new(ordered_choices: self.class.ordered_choices(object, aspect))
|
37
|
+
@options = options || {}
|
37
38
|
end
|
38
39
|
|
39
40
|
def decide
|
data/lib/status_tag/version.rb
CHANGED
data/lib/status_tag.rb
CHANGED
@@ -9,7 +9,7 @@ module StatusTag
|
|
9
9
|
|
10
10
|
extend StatusTag::Utils
|
11
11
|
|
12
|
-
def self.status_tag_presenter(object:, aspect: nil)
|
12
|
+
def self.status_tag_presenter(object:, aspect: nil, options: {})
|
13
13
|
# Support for STI and namespaced Objects is accomplished by
|
14
14
|
# first checking for a Presenter definition at the STI class level
|
15
15
|
# and then checking for a definition at the super class (generic) level.
|
@@ -19,25 +19,25 @@ module StatusTag
|
|
19
19
|
if aspect.nil?
|
20
20
|
# recommend locating class definition at app/presenters/status_tag/<klass>_presenter.rb
|
21
21
|
presenter_class = class_from_string("StatusTag::#{memo}Presenter")
|
22
|
-
presenter = presenter_class.new(object: object) if presenter_class
|
22
|
+
presenter = presenter_class.new(object: object, options: options) if presenter_class
|
23
23
|
else
|
24
24
|
presenter_class = class_from_string("StatusTag::#{memo}Presenters::#{camelize_underscored(aspect.to_s)}Presenter")
|
25
25
|
# recommend locating class definition at app/presenters/status_tag/<klass>_presenters/<aspect>_presenter.rb
|
26
|
-
presenter = presenter_class.new(object: object, aspect: aspect) if presenter_class
|
26
|
+
presenter = presenter_class.new(object: object, aspect: aspect, options: options) if presenter_class
|
27
27
|
end
|
28
28
|
break if presenter
|
29
29
|
last_namespace = memo.rindex("::")
|
30
30
|
memo = memo[0..(last_namespace-1)] if last_namespace # level up!
|
31
31
|
memo
|
32
32
|
end
|
33
|
-
presenter = NullPresenter.new(object: object) unless presenter
|
33
|
+
presenter = NullPresenter.new(object: object, aspect: aspect, options: options) unless presenter
|
34
34
|
presenter
|
35
35
|
end
|
36
36
|
|
37
37
|
# Same signature as Rails' `content_tag_for`.
|
38
38
|
# However, does not currently support object being multiple records like Rails' `content_tag_for` does
|
39
|
-
def self.status_tag_signature_for(tag, object, prefix = false, options = nil)
|
40
|
-
presenter = status_tag_presenter(object: object, aspect: prefix)
|
39
|
+
def self.status_tag_signature_for(tag, object, prefix = false, options = nil, status_tag_options = {})
|
40
|
+
presenter = status_tag_presenter(object: object, aspect: prefix, options: status_tag_options)
|
41
41
|
presenter.decide
|
42
42
|
text = presenter.text
|
43
43
|
return text, nil if presenter.noop?
|