class R18n::CustomFilterList
Filter list for I18n
object with custom disabled/enabled filters.
Public Class Methods
new(on, off)
click to toggle source
Calls superclass method
# File lib/r18n-core/filter_list.rb, line 114 def initialize(on, off) super() @on = Array(on).map { |i| Filters.defined[i] } @off = Array(off).map { |i| Filters.defined[i] } @changed_types = (@on + @off).map(&:types).flatten.uniq @changed_passive = (@on + @off).select(&:passive?) .map(&:types).flatten.uniq @changed_active = (@on + @off).reject(&:passive?) .map(&:types).flatten.uniq @on_by_type = {} @on.each do |filter| filter.types.each do |type| @on_by_type[type] ||= [] @on_by_type[type] << filter end end @off_by_type = {} @off.each do |filter| filter.types.each do |type| @off_by_type[type] ||= [] @off_by_type[type] << filter end end end
Public Instance Methods
active(type)
click to toggle source
# File lib/r18n-core/filter_list.rb, line 150 def active(type) enabled = Filters.active_enabled[type] return enabled unless @changed_active.include? type enabled = enabled.reject { |i| @off_by_type[type].include? i } enabled + @on_by_type[type].reject(&:passive) end
all(type)
click to toggle source
# File lib/r18n-core/filter_list.rb, line 158 def all(type) enabled = Filters.enabled[type] return enabled unless @changed_types.include? type enabled = enabled.reject { |i| @off_by_type[type].include? i } enabled + @on_by_type[type] end
hash()
click to toggle source
# File lib/r18n-core/filter_list.rb, line 166 def hash [@on, @off].hash end
passive(type)
click to toggle source
# File lib/r18n-core/filter_list.rb, line 142 def passive(type) enabled = Filters.passive_enabled[type] return enabled unless @changed_passive.include? type enabled = enabled.reject { |i| @off_by_type[type].include? i } enabled + @on_by_type[type].select(&:passive) end