Class: Maglev::Content::Base
- Inherits:
-
Object
- Object
- Maglev::Content::Base
- Extended by:
- Forwardable
- Defined in:
- app/components/maglev/content/base.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#setting ⇒ Object
Returns the value of attribute setting.
Instance Method Summary collapse
- #asset_host ⇒ Object
-
#dom_data ⇒ Object
rubocop:disable Rails/OutputSafety.
-
#initialize(scope, content, setting) ⇒ Base
constructor
Scope can be either a section or a block.
- #tag(_view_context, _options) ⇒ Object
-
#tag_data ⇒ Object
rubocop:enable Rails/OutputSafety.
- #tag_id ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(scope, content, setting) ⇒ Base
Scope can be either a section or a block
12 13 14 15 16 |
# File 'app/components/maglev/content/base.rb', line 12 def initialize(scope, content, setting) @scope = scope @content = content @setting = setting end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
9 10 11 |
# File 'app/components/maglev/content/base.rb', line 9 def content @content end |
#scope ⇒ Object
Returns the value of attribute scope.
9 10 11 |
# File 'app/components/maglev/content/base.rb', line 9 def scope @scope end |
#setting ⇒ Object
Returns the value of attribute setting.
9 10 11 |
# File 'app/components/maglev/content/base.rb', line 9 def setting @setting end |
Instance Method Details
#asset_host ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'app/components/maglev/content/base.rb', line 40 def asset_host case config.asset_host when nil nil when String config.asset_host when Proc instance_exec(site, &config.asset_host) end end |
#dom_data ⇒ Object
rubocop:disable Rails/OutputSafety
19 20 21 |
# File 'app/components/maglev/content/base.rb', line 19 def dom_data "data-maglev-id=\"#{tag_id}\"".html_safe end |
#tag(_view_context, _options) ⇒ Object
36 37 38 |
# File 'app/components/maglev/content/base.rb', line 36 def tag(_view_context, ) to_s end |
#tag_data ⇒ Object
rubocop:enable Rails/OutputSafety
24 25 26 |
# File 'app/components/maglev/content/base.rb', line 24 def tag_data { maglev_id: tag_id } end |
#tag_id ⇒ Object
28 29 30 |
# File 'app/components/maglev/content/base.rb', line 28 def tag_id "#{scope.id}.#{setting.id}" end |
#to_s ⇒ Object
32 33 34 |
# File 'app/components/maglev/content/base.rb', line 32 def to_s content || '' end |