Class: Alchemy::Ingredients::Datetime

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

Overview

A datetime 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(_maxlength = nil) ⇒ Object

Returns localized date for the Element#preview_text method.



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

def preview_text(_maxlength = nil)
  return "" unless value

  ::I18n.l(value, format: :"alchemy.ingredient_date")
end

#valueObject



10
11
12
# File 'app/models/alchemy/ingredients/datetime.rb', line 10

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