Class: ElasticRansack::Predicate

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_ransack/predicate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}) ⇒ Predicate

Returns a new instance of Predicate.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
# File 'lib/elastic_ransack/predicate.rb', line 5

def initialize(name, opts={})
  @name = name
  @regexp = opts[:regexp] || Regexp.new("^(.+)_#{@name}$")
  @query = opts[:query]
  raise(ArgumentError, ':query option is required') unless @query
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/elastic_ransack/predicate.rb', line 3

def name
  @name
end

#queryObject (readonly)

Returns the value of attribute query.



3
4
5
# File 'lib/elastic_ransack/predicate.rb', line 3

def query
  @query
end

#regexpObject (readonly)

Returns the value of attribute regexp.



3
4
5
# File 'lib/elastic_ransack/predicate.rb', line 3

def regexp
  @regexp
end