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.
14 15 16 |
# File 'lib/eac_rails_utils/menus/node.rb', line 14 def custom_label @custom_label end |
Instance Method Details
#auto_label ⇒ String
17 18 19 |
# File 'lib/eac_rails_utils/menus/node.rb', line 17 def auto_label ::I18n.t(label_translate_key) end |
#label(custom_label = nil) ⇒ String, self
23 24 25 26 27 28 29 30 |
# File 'lib/eac_rails_utils/menus/node.rb', line 23 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
33 34 35 |
# File 'lib/eac_rails_utils/menus/node.rb', line 33 def label_translate_key parent_label_translate_key end |
#parent_label_translate_key ⇒ String
38 39 40 41 42 43 |
# File 'lib/eac_rails_utils/menus/node.rb', line 38 def parent_label_translate_key [ parent_group.if_present(LABEL_TRANSLATE_KEY_PREFIX, &:parent_label_translate_key), key ].join(TRANSLATE_KEY_SEPARATOR) end |