module PIM::Filters

Public Instance Methods

all_filters() click to toggle source
# File pim.rb, line 7518
def all_filters
  filters = {}
  filters.merge!(@module_filters) if @module_filters
  add_parent_objects(filters) { |p| p.module_filters }
  filters
end
filter(name, label = nil, &block) click to toggle source
# File pim.rb, line 7492
def filter name, label = nil, &block

  name = to_sym(name)
  if label or block

    if module_filters.has_key? name
      if not data_module.has_option?(:ignore_defined_filters)
        raise "Filter with name '#{name}' is already defined in data model #{self}"
      else
        return module_filters[name]
      end
    end

    filter = PIM::FilterBuilder.build_filter(data_module, name, label, &block)
    module_filters[name] = filter

    filter

  elsif name.is_a? PIM::Filter
    filter
  else
    all_filters[name]
  end

end
filters_as_json() click to toggle source
# File pim.rb, line 7529
def filters_as_json
  filters = {}
  all_filters.sort.each do |(key, filter)|
    filters[key] = filter
  end
  as_json(filters)
end
module_filters() click to toggle source
# File pim.rb, line 7525
def module_filters
  @module_filters ||= {}
end