Sha256: 777370d54aa4b2718c99014283b6b06a6e3ae1a8d8023278305bdb27151c75fe
Contents?: true
Size: 1.84 KB
Versions: 5
Compression:
Stored size: 1.84 KB
Contents
require 'presentation/search' module Presentation class FieldSearch < Search # This method supports the configuration-on-initialization paradigm. It makes: # present = Presentation::FieldSearch.new(:fields => [ # {:a => {:type => :list, :options => %w(foo bar baz)}}, # :b, # {:c => :boolean} # ]) # # equivalent to: # # present = Presentation::FieldSearch.new # present.fields << {:a => {:type => :list, :options => %w(foo bar baz)}} # present.fields << :b # present.fields << {:c => :boolean} def fields=(args) args.each do |field| self.fields << field end end def fields @fields ||= Presenting::FieldSet.new(Field, :param, :type) end def compact @compact != false end attr_writer :compact class Field include Presenting::Configurable # the display name of the field. attr_reader :name def name=(val) @name = val.is_a?(Symbol) ? val.to_s.titleize : val end # the parameter name of the field. note that this is not necessarily the name of a database column or record attribute. # it simply needs to be recognized as a "field" by the controller logic. attr_reader :param def param=(val) self.name ||= val @param = val.to_s.underscore.downcase.gsub(' ', '_') end # the type of search interface for this field. supported options: # * :text (default) # * :checkbox # * :time [planned] # * :list [planned] def type @type ||= :text end attr_writer :type # extra options for the field. def options @options ||= {} end attr_writer :options end end end
Version data entries
5 entries across 5 versions & 1 rubygems