Class: Maglev::Content::CollectionItem
- Defined in:
- app/components/maglev/content/collection_item.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#asset_host, #dom_data, #initialize, #tag_data, #tag_id
Constructor Details
This class inherits a constructor from Maglev::Content::Base
Instance Method Details
#exists? ⇒ Boolean
6 7 8 |
# File 'app/components/maglev/content/collection_item.rb', line 6 def exists? item.present? end |
#item ⇒ Object
14 15 16 |
# File 'app/components/maglev/content/collection_item.rb', line 14 def item (content || {})[:item] end |
#tag(view_context, options = {}, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/components/maglev/content/collection_item.rb', line 18 def tag(view_context, = {}, &block) return unless item && block_given? view_context.tag.public_send( .delete(:html_tag)&.to_sym || :div, view_context.capture(item, &block), **{ data: (.delete(:data) || {}).merge(tag_data) }.merge() ) end |
#to_s ⇒ Object
10 11 12 |
# File 'app/components/maglev/content/collection_item.rb', line 10 def to_s item.inspect end |