actionnav 1.0.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31c53dde826c66ce6f21c370796c69b4b001e49fbdc077cc2a6c83fb059de49c
4
- data.tar.gz: 22e4c87bd986c6aa80555efe2f4f0a3f7df8baddd260148825843464a67ff02c
3
+ metadata.gz: b42909b04fcc4c81f604aaee142e8fbd27371f7c59568f0a0acf695c6610843a
4
+ data.tar.gz: ee1bd67e110480eaab050f7dc51b3ad4a01fb5e838a8cf4e75d59a014ac15588
5
5
  SHA512:
6
- metadata.gz: e056df0d8b2c7939b5c03f4e18b55ca81e61a1ea3cc41e29a7c5da74f0748d1ffc0448273add4ab14d59609848175a920cf06fbe7b7fb31be69ca59c4502babd
7
- data.tar.gz: ae1fb1049e207e5f9f420ec2a001b69276a0771efad04fdc70ed76a3a2742e7a2a6faa4d97bc84ea6c0859210520ee5fbb999edd24ae2e6541ffe2f6f9138db1
6
+ metadata.gz: 332bbcf82df0fb68b1c13a6a7f27387ad18734f03d07dd325838e792ecdc79ad7e54299551634ef3c1d4d5a62d94a8a69feff7cbf00ac5c30d12c153f8e331cd
7
+ data.tar.gz: 38eaefc923ba32c4c66effb9b2dcff8d69a8ccbfddb3e6d40f1d8de200bcfee01ebd63efa66a5261d007f5a153f6e70a4782deae4c26dcd863d9cff20ae9ac90
@@ -12,6 +12,7 @@ module ActionNav
12
12
  def initialize(controller)
13
13
  @controller = controller
14
14
  @active_paths = []
15
+ @context = {}
15
16
  end
16
17
 
17
18
  # The controller that initialized this navigation.
@@ -20,6 +21,11 @@ module ActionNav
20
21
  attr_reader :controller
21
22
  attr_reader :active_paths
22
23
 
24
+ # The context for this navigation.
25
+ #
26
+ # @return [Hash]
27
+ attr_reader :context
28
+
23
29
  # Return a full list of items for this instance as
24
30
  # instances.
25
31
  #
@@ -50,6 +56,15 @@ module ActionNav
50
56
  end
51
57
  end
52
58
 
59
+ # Add context to this navigation.
60
+ #
61
+ # @param key [Symbol]
62
+ # @param value [Object]
63
+ # @return [Hash]
64
+ def add_context(key, value)
65
+ @context[key] = value
66
+ end
67
+
53
68
  # Add a new item to this navigation
54
69
  #
55
70
  # @param id [Symbol]
@@ -15,6 +15,7 @@ module ActionNav
15
15
  attr_accessor :url
16
16
  attr_accessor :description
17
17
  attr_accessor :icon
18
+ attr_accessor :meta
18
19
  attr_accessor :hide_unless
19
20
  attr_accessor :count
20
21
 
@@ -21,6 +21,10 @@ module ActionNav
21
21
  @item.icon = block_given? ? block : icon
22
22
  end
23
23
 
24
+ def meta(meta = {}, &block)
25
+ @item.meta = block_given? ? block : meta
26
+ end
27
+
24
28
  def hide_unless(&block)
25
29
  @item.hide_unless = block
26
30
  end
@@ -47,6 +47,10 @@ module ActionNav
47
47
  cache(:url) { parse(@item.url, "/")}
48
48
  end
49
49
 
50
+ def meta
51
+ cache(:meta) { parse(@item.meta, {}) }
52
+ end
53
+
50
54
  def icon
51
55
  cache(:icon) { parse(@item.icon) }
52
56
  end
@@ -73,7 +77,9 @@ module ActionNav
73
77
 
74
78
  def parse(item, default = nil)
75
79
  if item.is_a?(Proc)
76
- @base.controller.instance_eval(&item)
80
+ @base.controller.instance_exec(@base.context, &item)
81
+ elsif item.is_a?(Hash)
82
+ item
77
83
  elsif item
78
84
  item.to_s
79
85
  else
@@ -1,3 +1,3 @@
1
1
  module ActionNav
2
- VERSION = "1.0.3" # x-release-please-version
2
+ VERSION = "1.2.0" # x-release-please-version
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionnav
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-10 00:00:00.000000000 Z
11
+ date: 2024-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  requirements: []
63
- rubygems_version: 3.3.26
63
+ rubygems_version: 3.3.27
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: This gem provides a friendly way to manage application navigation.