Class: Alchemy::Ingredients::Boolean

Inherits:
Alchemy::Ingredient show all
Defined in:
app/models/alchemy/ingredients/boolean.rb

Overview

A boolean value

Constant Summary

Constants included from SearchableResource

SearchableResource::SEARCHABLE_COLUMN_TYPES

Instance Method Summary collapse

Methods inherited from Alchemy::Ingredient

allow_settings, allowed_settings, #as_view_component, #definition, #deprecated?, #has_hint?, #has_tinymce?, #has_validations?, normalize_type, #partial_name, #preview_ingredient?, related_object_alias, #settings, #to_partial_path, translated_label_for

Methods included from Hints

#has_hint?, #hint

Methods included from SearchableResource

#ransackable_associations, #ransackable_attributes, #ransortable_attributes

Instance Method Details

#preview_text(_max_length = nil) ⇒ Object

The localized value

Used by the Element#preview_text method.



16
17
18
19
20
# File 'app/models/alchemy/ingredients/boolean.rb', line 16

def preview_text(_max_length = nil)
  return if value.nil?

  Alchemy.t(value.to_s, scope: "ingredient_values.boolean")
end

#valueObject



8
9
10
# File 'app/models/alchemy/ingredients/boolean.rb', line 8

def value
  ActiveRecord::Type::Boolean.new.cast(self[:value])
end