Class: MySQL::Search::Queries::UpdatedSourcesQuery
- Inherits:
-
Object
- Object
- MySQL::Search::Queries::UpdatedSourcesQuery
- Defined in:
- lib/mysql/search/queries/updated_sources_query.rb
Overview
Queries updated sources for search indexing.
Instance Attribute Summary collapse
-
#source_class_name ⇒ Object
readonly
Returns the value of attribute source_class_name.
-
#source_relation ⇒ Object
readonly
Returns the value of attribute source_relation.
Instance Method Summary collapse
- #call(time_ago) ⇒ Object
-
#initialize(source_relation) ⇒ UpdatedSourcesQuery
constructor
A new instance of UpdatedSourcesQuery.
Constructor Details
#initialize(source_relation) ⇒ UpdatedSourcesQuery
Returns a new instance of UpdatedSourcesQuery.
10 11 12 13 |
# File 'lib/mysql/search/queries/updated_sources_query.rb', line 10 def initialize(source_relation) @source_relation = source_relation.all @source_class_name = "#{source_relation.all.klass.name}Source" end |
Instance Attribute Details
#source_class_name ⇒ Object (readonly)
Returns the value of attribute source_class_name.
8 9 10 |
# File 'lib/mysql/search/queries/updated_sources_query.rb', line 8 def source_class_name @source_class_name end |
#source_relation ⇒ Object (readonly)
Returns the value of attribute source_relation.
8 9 10 |
# File 'lib/mysql/search/queries/updated_sources_query.rb', line 8 def source_relation @source_relation end |
Instance Method Details
#call(time_ago) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/mysql/search/queries/updated_sources_query.rb', line 15 def call(time_ago) joins_args = source_class_name.constantize.joins_args relation = source_relation.left_joins(joins_args).where(updated_at: time_ago..) append_conditions(relation, source_relation, joins_args, time_ago) end |