Class: Maglev::Content::Base
- Inherits:
-
Object
- Object
- Maglev::Content::Base
- Extended by:
- Forwardable
- Includes:
- Inspector
- 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
Methods included from Inspector
Constructor Details
#initialize(scope, content, setting) ⇒ Base
Scope can be either a section or a block
14 15 16 17 18 |
# File 'app/components/maglev/content/base.rb', line 14 def initialize(scope, content, setting) @scope = scope @content = content @setting = setting end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
11 12 13 |
# File 'app/components/maglev/content/base.rb', line 11 def content @content end |
#scope ⇒ Object
Returns the value of attribute scope.
11 12 13 |
# File 'app/components/maglev/content/base.rb', line 11 def scope @scope end |
#setting ⇒ Object
Returns the value of attribute setting.
11 12 13 |
# File 'app/components/maglev/content/base.rb', line 11 def setting @setting end |
Instance Method Details
#asset_host ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'app/components/maglev/content/base.rb', line 42 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
21 22 23 |
# File 'app/components/maglev/content/base.rb', line 21 def dom_data "data-maglev-id=\"#{tag_id}\"".html_safe end |
#tag(_view_context, _options) ⇒ Object
38 39 40 |
# File 'app/components/maglev/content/base.rb', line 38 def tag(_view_context, ) to_s end |
#tag_data ⇒ Object
rubocop:enable Rails/OutputSafety
26 27 28 |
# File 'app/components/maglev/content/base.rb', line 26 def tag_data { maglev_id: tag_id } end |
#tag_id ⇒ Object
30 31 32 |
# File 'app/components/maglev/content/base.rb', line 30 def tag_id "#{scope.id}.#{setting.id}" end |
#to_s ⇒ Object
34 35 36 |
# File 'app/components/maglev/content/base.rb', line 34 def to_s content || '' end |