status_tag 0.1.2 → 0.1.3

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: 291eb59983500803ea263a4778fe89dad8bbe5d2
4
- data.tar.gz: afd44c1c01e1bfff6fc52527d14e7c692bc0ffe9
3
+ metadata.gz: 50db7516df1a9992517cc1617e0a73e084166854
4
+ data.tar.gz: 92381fed4bb48a184477dc559e976a58f7db68aa
5
5
  SHA512:
6
- metadata.gz: 3a25ffef8e4993d0d6e27c3a36bb33ae11202fdb802feac0379bee4b36b25e7661a1f760e380ba4abae1021d10f955aa7ca98d2cf1ba2f9f2db14b6a96f602f0
7
- data.tar.gz: 43ddd21610f2b809dbe5d50e5f7721f81196762af031e9f1f228a85173a7f1cfe8e8f49b437fa13ed440fa382e2fc3d9de929484e274ff0c97554adc1d8edc27
6
+ metadata.gz: 8e5748ea0f37e90cae1ce69a462b159bb121e84a18ee33afd966a9982df1bcd8c7b1a01f16c8204bd0910d77b14d79acd2646633744af69b6c7b0dbccaf25c4b
7
+ data.tar.gz: 53b452d3f382b2400f18d30c442bb895048bf03ec625659033ce65d48d06a632cbf173d35439ecce9af1eabcc9f7ea243127794a3de1c03d02e0e7fc624da1cd
@@ -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
@@ -1,3 +1,3 @@
1
1
  module StatusTag
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: status_tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling