Class: Superform::Rails::Components::Base
- Inherits:
-
Superform::Rails::Component
- Object
- Superform::Rails::Components::Base
- Defined in:
- lib/superform/rails/components/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dom ⇒ Object
readonly
Returns the value of attribute dom.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Instance Method Summary collapse
- #field_attributes ⇒ Object
- #focus(value = true) ⇒ Object
-
#initialize(field, attributes: nil, **attributes_kwargs) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(field, attributes: nil, **attributes_kwargs) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/superform/rails/components/base.rb', line 9 def initialize(field, attributes: nil, **attributes_kwargs) @field = field if attributes warn "[DEPRECATION] Passing `attributes:` keyword to #{self.class.name} is deprecated. " \ "Pass HTML attributes as keyword arguments directly instead: " \ "#{self.class.name}.new(field, **attributes)" @attributes = attributes.merge(attributes_kwargs) else @attributes = attributes_kwargs end end |
Instance Attribute Details
#dom ⇒ Object (readonly)
Returns the value of attribute dom.
5 6 7 |
# File 'lib/superform/rails/components/base.rb', line 5 def dom @dom end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
5 6 7 |
# File 'lib/superform/rails/components/base.rb', line 5 def field @field end |
Instance Method Details
#field_attributes ⇒ Object
21 22 23 |
# File 'lib/superform/rails/components/base.rb', line 21 def field_attributes {} end |
#focus(value = true) ⇒ Object
25 26 27 28 |
# File 'lib/superform/rails/components/base.rb', line 25 def focus(value = true) @attributes[:autofocus] = value self end |