Sha256: 67e801a6e530e553eb175909c178df64cddb48feb7593af867faa71498d0ddf0

Contents?: true

Size: 710 Bytes

Versions: 4

Compression:

Stored size: 710 Bytes

Contents

module Tableficate
  class Base
    extend Tableficate::Finder

    def self.scope(model = nil, &block)
      if block_given?
        @scope = block.call
      else
        @scope = model.to_s.camelize.constantize
      end
    end

    def self.default_sort(name, dir = 'asc')
      @default_sort = [name, dir]
    end

    def self.column(name, options = {})
      @sort ||= {}

      @sort[name] = options[:sort] if options[:sort].present?
    end

    def self.filter(name, options = {}, &block)
      @filter ||= {}

      if block_given?
        @filter[name] = block
      else
        options.reverse_merge!(
          field: name
        )

        @filter[name] = options
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tableficate-0.1.3 lib/tableficate/base.rb
tableficate-0.1.2 lib/tableficate/base.rb
tableficate-0.1.1 lib/tableficate/base.rb
tableficate-0.0.1 lib/tableficate/base.rb