Class: BulmaPhlex::Rails::BaseDisplay
- Inherits:
-
Base
- Object
- Base
- BulmaPhlex::Rails::BaseDisplay
- Defined in:
- lib/bulma_phlex/rails/components/displays/base_display.rb
Overview
# Base Display
Base class for read-only display fields styled with Bulma.
This allows the model to be passed via the ‘model:` option or as the first argument. When the model is passed as an option, the method is assumed to be the first argument.
Direct Known Subclasses
Constant Summary collapse
- FORM_FIELD_OPTIONS =
Keyword arguments accepted by BulmaPhlex::FormField
BulmaPhlex::FormField .instance_method(:initialize) .parameters .map { |_, name| name } .freeze
Instance Method Summary collapse
-
#initialize(model, method = nil, **options) ⇒ BaseDisplay
constructor
A new instance of BaseDisplay.
- #view_template ⇒ Object
Constructor Details
#initialize(model, method = nil, **options) ⇒ BaseDisplay
Returns a new instance of BaseDisplay.
20 21 22 23 24 |
# File 'lib/bulma_phlex/rails/components/displays/base_display.rb', line 20 def initialize(model, method = nil, **) @model = .fetch(:model, model) @method = method || model @options = end |
Instance Method Details
#view_template ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/bulma_phlex/rails/components/displays/base_display.rb', line 26 def view_template = @options.slice(*FORM_FIELD_OPTIONS) BulmaPhlex::FormField(**) do |field| field.label { label(class: "label") { label_text } } field.control { control_content } end end |