Class: Ransack::Ransacker
- Inherits:
-
Object
- Object
- Ransack::Ransacker
- Defined in:
- lib/ransack/ransacker.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #attr_from(bindable) ⇒ Object
-
#initialize(klass, name, opts = {}, &block) ⇒ Ransacker
constructor
A new instance of Ransacker.
Constructor Details
#initialize(klass, name, opts = {}, &block) ⇒ Ransacker
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
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/ransack/ransacker.rb', line 4 def args @args end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
4 5 6 |
# File 'lib/ransack/ransacker.rb', line 4 def formatter @formatter end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/ransack/ransacker.rb', line 4 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/ransack/ransacker.rb', line 4 def type @type end |
Instance Method Details
#attr_from(bindable) ⇒ Object
19 20 21 |
# File 'lib/ransack/ransacker.rb', line 19 def attr_from(bindable) call(*args.map { |arg| bindable.send(arg) }) end |