Sha256: bfa1d0b3fa86044cf757a4fbf89c22f1aa3c0a7e10d1e02ec1a2f88b8775fc50

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 Bytes

Contents

##
# Filter
#
module Outpost
  module List
    class Filter
      BOOLEAN_COLLECT = [["Yes", 1], ["No", 0]]

      attr_accessor :attribute, :collection, :title, :list
      
      def initialize(attribute, list, options={})
        @attribute  = attribute.to_s
        @list       = list
        @title      = options[:title] || @attribute.titleize
        
        collection = options[:collection]
        @collection = begin
          case collection
          when NilClass
            # TODO Automatically detect column type
          when Proc
            collection
          when Symbol
            send "_#{collection}_collection"
          end
        end
      end
      

      private
      
      def _boolean_collection
        -> { BOOLEAN_COLLECT }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-cms-0.0.3 lib/outpost/list/filter.rb