Class: Maglev::Content::CollectionItem
- Inherits:
-
Base
- Object
- Base
- Maglev::Content::CollectionItem
show all
- Defined in:
- app/components/maglev/content/collection_item.rb
Instance Attribute Summary
Attributes inherited from Base
#content, #scope, #setting
Instance Method Summary
collapse
Methods inherited from Base
#asset_host, #dom_data, #initialize, #tag_data, #tag_id
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, options = {}, &block)
return unless item && block_given?
view_context.tag.public_send(
options.delete(:html_tag)&.to_sym || :div,
view_context.capture(item, &block),
**{ data: (options.delete(:data) || {}).merge(tag_data) }.merge(options)
)
end
|
#to_s ⇒ Object
10
11
12
|
# File 'app/components/maglev/content/collection_item.rb', line 10
def to_s
item.inspect
end
|