Class: Ransack::Ransacker
- Inherits:
-
Object
- Object
- Ransack::Ransacker
- Defined in:
- lib/ransack/ransacker.rb
Instance Attribute Summary (collapse)
-
- (Object) args
readonly
Returns the value of attribute args.
-
- (Object) formatter
readonly
Returns the value of attribute formatter.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) type
readonly
Returns the value of attribute type.
Instance Method Summary (collapse)
- - (Object) attr_from(bindable)
-
- (Ransacker) initialize(klass, name, opts = {}, &block)
constructor
A new instance of Ransacker.
Constructor Details
- (Ransacker) initialize(klass, name, opts = {}, &block)
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 |