module Alchemy::Hints
Public Instance Methods
has_hint?()
click to toggle source
Returns true if the element has a hint defined
# File lib/alchemy/hints.rb, line 47 def has_hint? !!definition[:hint] end
hint()
click to toggle source
Returns a hint
To add a hint to a ingredient pass +hint: true+ to the element definition in its element.yml
Then the hint itself is placed in the locale yml files.
Alternativly you can pass the hint itself to the hint key.
Locale Example:¶ ↑
# elements.yml - name: headline ingredients: - role: headline type: Text hint: true # config/locales/de.yml de: ingredient_hints: headline: Lorem ipsum
Hint Key Example:¶ ↑
- name: headline ingredients: - role: headline type: Text hint: Lorem ipsum
@return String
# File lib/alchemy/hints.rb, line 37 def hint hint = definition[:hint] if hint == true Alchemy.t(hint_translation_attribute, scope: hint_translation_scope) else hint end end
Private Instance Methods
hint_translation_attribute()
click to toggle source
# File lib/alchemy/hints.rb, line 53 def hint_translation_attribute name end
hint_translation_scope()
click to toggle source
# File lib/alchemy/hints.rb, line 57 def hint_translation_scope "#{self.class.model_name.to_s.demodulize.downcase}_hints" end