Sha256: a7191ad8486dc9128bf3363abf741a3a2816b407a3e861b29a6695f0c0d13ce8
Contents?: true
Size: 752 Bytes
Versions: 2
Compression:
Stored size: 752 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) option = self.options[:select] if option.respond_to?(:call) option.arity == 1 ? option.call(object) : option.call else option end end def include_blank self.options.has_key?(:include_blank) ? options[:include_blank] : true unless self.prompt end def prompt self.options.has_key?(:prompt) ? options[:prompt] : false end def strict self.options[:strict] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
datagrid-0.8.4 | lib/datagrid/filters/enum_filter.rb |
datagrid-0.8.3 | lib/datagrid/filters/enum_filter.rb |