Sha256: b788686207b09a4ed3a8f4da0641514350e87845e69dc8b6322bdd95ff8de84f
Contents?: true
Size: 818 Bytes
Versions: 1
Compression:
Stored size: 818 Bytes
Contents
class Datagrid::Filters::EnumFilter < Datagrid::Filters::BaseFilter def initialize(*args) super(*args) raise Datagrid::ConfigurationError, ":select option not specified" unless options[:select] end def parse(value) return nil if self.strict && !select.include?(value) value end def select(object = nil) select = self.options[:select] if select.is_a?(Symbol) object.send(select) elsif select.respond_to?(:call) Datagrid::Utils.apply_args(object, &select) else select end end def include_blank unless self.prompt self.options.has_key?(:include_blank) ? options[:include_blank] : !multiple end end def prompt self.options.has_key?(:prompt) ? options[:prompt] : false end def strict self.options[:strict] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datagrid-0.9.3 | lib/datagrid/filters/enum_filter.rb |