class R18n::FilterList
Superclass for GlobalFilterList
and
CustomFilterList
with filters processing.
Public Instance Methods
active(type)
click to toggle source
List of enable active filters.
# File lib/r18n-core/filter_list.rb, line 83 def active(type) [] end
all(type)
click to toggle source
List of enable filters.
# File lib/r18n-core/filter_list.rb, line 88 def all(type) [] end
enabled(filters_type, type)
click to toggle source
Array of enabled filters with filters_type
for
type
.
# File lib/r18n-core/filter_list.rb, line 67 def enabled(filters_type, type) if filters_type == :passive passive(type) elsif filters_type == :active active(type) else all(type) end end
passive(type)
click to toggle source
List of enable passive filters.
# File lib/r18n-core/filter_list.rb, line 78 def passive(type) [] end
process(filters_type, type, value, locale, path, params)
click to toggle source
Process value
by filters in enabled
.
# File lib/r18n-core/filter_list.rb, line 25 def process(filters_type, type, value, locale, path, params) config = { locale: locale, path: path } enabled(filters_type, type).each do |filter| value = filter.call(value, config, *params) end if value.is_a? String value = TranslatedString.new(value, locale, path) process_string(filters_type, value, config, params) else value end end
process_string(filters_type, value, config, params)
click to toggle source
Process value
by global filters in enabled
.
# File lib/r18n-core/filter_list.rb, line 51 def process_string(filters_type, value, config, params) if config.is_a? String config = { locale: value.locale, path: config } end enabled(filters_type, String).each do |f| value = f.call(value, config, *params) end if value.class == String TranslatedString.new(value, config[:locale], config[:path]) else value end end
process_typed(filters_type, typed_value, params)
click to toggle source
Shortcut ot process `R18n::Typed`.
# File lib/r18n-core/filter_list.rb, line 41 def process_typed(filters_type, typed_value, params) process(filters_type, typed_value.type, typed_value.value, typed_value.locale, typed_value.path, params) end