Class: Satis::Editor::Component
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Satis::Editor::Component
- Defined in:
- app/components/satis/editor/component.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from ApplicationComponent
Instance Method Summary collapse
-
#initialize(form: nil, attribute: nil, **options) ⇒ Component
constructor
A new instance of Component.
- #lang ⇒ Object
- #readonly? ⇒ Boolean
- #value ⇒ Object
Methods inherited from ApplicationComponent
Constructor Details
#initialize(form: nil, attribute: nil, **options) ⇒ Component
Returns a new instance of Component.
7 8 9 10 11 |
# File 'app/components/satis/editor/component.rb', line 7 def initialize(form: nil, attribute: nil, **) @form = form @attribute = attribute @options = end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
6 7 8 |
# File 'app/components/satis/editor/component.rb', line 6 def attribute @attribute end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
6 7 8 |
# File 'app/components/satis/editor/component.rb', line 6 def form @form end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'app/components/satis/editor/component.rb', line 6 def @options end |
Instance Method Details
#lang ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/components/satis/editor/component.rb', line 17 def lang # Mode is there for older code, it's deprecated if @options[:lang] @options[:lang] elsif @options[:mode] case @options[:mode] when 'application/yaml' 'yaml' when 'application/json' 'json' when 'text/x-ruby' '' end end end |
#readonly? ⇒ Boolean
13 14 15 |
# File 'app/components/satis/editor/component.rb', line 13 def readonly? (@options[:readonly].is_a?(TrueClass) || @options[:readonly].is_a?(FalseClass)) ? @options[:readonly] : content? end |
#value ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'app/components/satis/editor/component.rb', line 34 def value if content? html_escape_once(content) elsif [:input_html]&.[](:value) [:input_html][:value] elsif form form.object.send(attribute) end end |