Class: I18n::Backend::SequelBitemporal::TranslationVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/backend/sequel_bitemporal/translation.rb

Constant Summary collapse

TRUTHY_CHAR =
"\001"
FALSY_CHAR =
"\002"

Instance Method Summary collapse

Instance Method Details

#interpolates?(key) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/i18n/backend/sequel_bitemporal/translation.rb', line 75

def interpolates?(key)
  self.interpolations.include?(key) if self.interpolations
end

#interpolationsObject

Sequel do not support default value for serialize_attributes



71
72
73
# File 'lib/i18n/backend/sequel_bitemporal/translation.rb', line 71

def interpolations
  super || []
end

#valueObject



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/i18n/backend/sequel_bitemporal/translation.rb', line 79

def value
  value = super
  if is_proc
    Kernel.eval(value)
  elsif value == FALSY_CHAR
    false
  elsif value == TRUTHY_CHAR
    true
  else
    value
  end
end

#value=(value) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'lib/i18n/backend/sequel_bitemporal/translation.rb', line 92

def value=(value)
  if value === false
    value = FALSY_CHAR
  elsif value === true
    value = TRUTHY_CHAR
  end

  super(value)
end