Module: Lookbook::Taggable
- Included in:
- Preview, PreviewExample, PreviewGroup
- Defined in:
- lib/lookbook/taggable.rb
Instance Method Summary collapse
-
#code_object ⇒ Object
private.
- #lookbook_display_params ⇒ Object
- #lookbook_group ⇒ Object
- #lookbook_hidden? ⇒ Boolean
- #lookbook_label ⇒ Object
- #lookbook_notes ⇒ Object
Instance Method Details
#code_object ⇒ Object
private
42 43 44 |
# File 'lib/lookbook/taggable.rb', line 42 def code_object @code_object ||= Lookbook::Engine.parser.get_code_object(taggable_object_path) end |
#lookbook_display_params ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/lookbook/taggable.rb', line 23 def lookbook_display_params display_params = {}.with_indifferent_access if code_object&.(:display).present? code_object.(:display).each do |tag| parts = tag.text.strip.match(/^([^\s]*)\s?(.*)$/) if parts.present? begin display_params[parts[1]] = YAML.safe_load(parts[2] || "~") rescue SyntaxError => err Rails.logger.error("\nš [Lookbook] Invalid JSON in @display tag.\nš [Lookbook] (#{err})\n") end end end end display_params end |
#lookbook_group ⇒ Object
19 20 21 |
# File 'lib/lookbook/taggable.rb', line 19 def lookbook_group code_object&.group end |
#lookbook_hidden? ⇒ Boolean
3 4 5 6 7 |
# File 'lib/lookbook/taggable.rb', line 3 def lookbook_hidden? if code_object&.tag(:hidden) code_object.tag(:hidden).text.strip != "false" end end |
#lookbook_label ⇒ Object
9 10 11 |
# File 'lib/lookbook/taggable.rb', line 9 def lookbook_label code_object&.tag(:label)&.text end |
#lookbook_notes ⇒ Object
13 14 15 16 17 |
# File 'lib/lookbook/taggable.rb', line 13 def lookbook_notes if code_object&.docstring code_object.docstring.to_s.strip end end |