Class: EacRailsUtils::Menus::Node
- Inherits:
-
Object
- Object
- EacRailsUtils::Menus::Node
- Defined in:
- lib/eac_rails_utils/menus/node.rb
Constant Summary collapse
- LABEL_TRANSLATE_KEY_PREFIX =
'eac_rails_utils.menus'
- TRANSLATE_KEY_SEPARATOR =
'.'
Instance Attribute Summary collapse
-
#custom_label ⇒ Object
readonly
Returns the value of attribute custom_label.
Instance Method Summary collapse
- #auto_label ⇒ String
- #label(custom_label = nil) ⇒ String, self
- #label_translate_key ⇒ String
- #parent_label_translate_key ⇒ String
Instance Attribute Details
#custom_label ⇒ Object
Returns the value of attribute custom_label.
12 13 14 |
# File 'lib/eac_rails_utils/menus/node.rb', line 12 def custom_label @custom_label end |
Instance Method Details
#auto_label ⇒ String
15 16 17 |
# File 'lib/eac_rails_utils/menus/node.rb', line 15 def auto_label ::I18n.t(label_translate_key) end |
#label(custom_label = nil) ⇒ String, self
21 22 23 24 25 26 27 28 |
# File 'lib/eac_rails_utils/menus/node.rb', line 21 def label(custom_label = nil) if custom_label.present? self.custom_label = custom_label self else (self.custom_label || auto_label).call_if_proc end end |
#label_translate_key ⇒ String
31 32 33 |
# File 'lib/eac_rails_utils/menus/node.rb', line 31 def label_translate_key parent_label_translate_key end |
#parent_label_translate_key ⇒ String
36 37 38 39 40 41 |
# File 'lib/eac_rails_utils/menus/node.rb', line 36 def parent_label_translate_key [ parent_group.if_present(LABEL_TRANSLATE_KEY_PREFIX, &:parent_label_translate_key), key ].join(TRANSLATE_KEY_SEPARATOR) end |