Class: Ransack::Ransacker

Inherits:
Object
  • Object
show all
Defined in:
lib/ransack/ransacker.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Ransacker) initialize(klass, name, opts = {}, &block)

Returns a new instance of Ransacker



8
9
10
11
12
13
14
15
16
17
# File 'lib/ransack/ransacker.rb', line 8

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

Instance Attribute Details

- (Object) args (readonly)

Returns the value of attribute args



4
5
6
# File 'lib/ransack/ransacker.rb', line 4

def args
  @args
end

- (Object) formatter (readonly)

Returns the value of attribute formatter



4
5
6
# File 'lib/ransack/ransacker.rb', line 4

def formatter
  @formatter
end

- (Object) name (readonly)

Returns the value of attribute name



4
5
6
# File 'lib/ransack/ransacker.rb', line 4

def name
  @name
end

- (Object) type (readonly)

Returns the value of attribute type



4
5
6
# File 'lib/ransack/ransacker.rb', line 4

def type
  @type
end

Instance Method Details

- (Object) attr_from(bindable)



19
20
21
# File 'lib/ransack/ransacker.rb', line 19

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