Class: BulmaPhlex::Rails::CurrencyDisplay
- Inherits:
-
BaseDisplay
- Object
- Base
- BaseDisplay
- BulmaPhlex::Rails::CurrencyDisplay
- Includes:
- Phlex::Rails::Helpers::NumberToCurrency
- Defined in:
- lib/bulma_phlex/rails/components/displays/currency_display.rb
Overview
# Currency Display
A read-only display field styled with Bulma that formats a numeric value as currency. This component leverages Rails’ ‘number_to_currency` helper for formatting.
Currency options can be passed as a hash to customize the formatting.
#### Arguments
-
‘model`: ActiveRecord Model - The model containing the currency attribute. This can also be passed via the `options` (helpful when using `with_options`).
-
‘method`: Symbol or String - The attribute method name for the currency field.
-
‘options`: Hash - Additional options for the display field. This can include the `currency_options` key, which should be a hash of options passed to `number_to_currency`.
Constant Summary
Constants inherited from BaseDisplay
BaseDisplay::FORM_FIELD_OPTIONS
Instance Method Summary collapse
-
#initialize(model, method = nil, **options) ⇒ CurrencyDisplay
constructor
A new instance of CurrencyDisplay.
Methods inherited from BaseDisplay
Constructor Details
#initialize(model, method = nil, **options) ⇒ CurrencyDisplay
Returns a new instance of CurrencyDisplay.
23 24 25 26 |
# File 'lib/bulma_phlex/rails/components/displays/currency_display.rb', line 23 def initialize(model, method = nil, **) super(model, method, **.except(:currency_options)) @currency_options = .fetch(:currency_options, {}) end |