Sha256: 623f7a84ffd5fb2fdeb3ab72fc3544d13920084427aab804b6695c6f63627b05

Contents?: true

Size: 599 Bytes

Versions: 46

Compression:

Stored size: 599 Bytes

Contents

module Ransack
  class Ransacker

    attr_reader :name, :type, :formatter, :args

    delegate :call, :to => :@callable

    def initialize(klass, name, opts = {}, &block)
      @klass, @name = klass, name

      @type = opts[:type] || :string
      @args = opts[:args] || [:parent]
      @formatter = opts[:formatter]
      @callable = opts[:callable] || block ||
                  (@klass.method(name) if @klass.respond_to?(name)) ||
                  proc { |parent| parent.table[name] }
    end

    def attr_from(bindable)
      call(*args.map { |arg| bindable.send(arg) })
    end

  end
end

Version data entries

46 entries across 46 versions & 4 rubygems

Version Path
ransack-1.8.9 lib/ransack/ransacker.rb
ransack-1.8.8 lib/ransack/ransacker.rb
ransack-1.8.7 lib/ransack/ransacker.rb
ransack-1.8.6 lib/ransack/ransacker.rb
ransack-1.8.4 lib/ransack/ransacker.rb
ransack-1.8.3 lib/ransack/ransacker.rb
ransack-1.8.2 lib/ransack/ransacker.rb
ransack-1.8.1 lib/ransack/ransacker.rb
ransack-1.8.0 lib/ransack/ransacker.rb
ransack-1.7.0 lib/ransack/ransacker.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/ransack-1.6.6/lib/ransack/ransacker.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/ransack-1.6.6/lib/ransack/ransacker.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/ransack-1.6.6/lib/ransack/ransacker.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/ransack-1.6.2/lib/ransack/ransacker.rb
ransack-1.6.6 lib/ransack/ransacker.rb
ransack-1.6.5 lib/ransack/ransacker.rb
ransack-1.6.4 lib/ransack/ransacker.rb
ransack-1.6.3 lib/ransack/ransacker.rb
ransack-1.6.2 lib/ransack/ransacker.rb
ransack-1.6.1 lib/ransack/ransacker.rb