Class: ActiveRecordSeek::Component
Instance Method Summary
collapse
#after_initialize, #initialize, #instance_variable_reset, #instance_variable_yield, #set
Instance Method Details
#apply(query) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/active_record_seek/component.rb', line 45
def apply(query)
Middleware.middleware.each do |middleware|
action = middleware.call(self)
case action
when :skip then return query
else
end
end
operator_class.new(component: self).apply(query)
end
|
#association=(new_association) ⇒ Object
33
34
35
|
# File 'lib/active_record_seek/component.rb', line 33
def association=(new_association)
@association = new_association == "self" ? table_name : new_association
end
|
#is_base_query_component? ⇒ Boolean
37
38
39
|
# File 'lib/active_record_seek/component.rb', line 37
def is_base_query_component?
association == table_name
end
|
#key ⇒ Object
29
30
31
|
# File 'lib/active_record_seek/component.rb', line 29
def key
"#{namespace}.#{association}.#{column}.#{operator}"
end
|
#key=(new_key) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/active_record_seek/component.rb', line 19
def key=(new_key)
self.original_key = new_key.to_s
parts = original_key.split(".").select(&:present?)
self.operator = parts.pop
self.column = parts.pop
self.association = parts.pop || "self"
self.namespace = parts.pop || "default"
key
end
|
#operator_class ⇒ Object
41
42
43
|
# File 'lib/active_record_seek/component.rb', line 41
def operator_class
"::ActiveRecordSeek::Operators::#{operator.camelcase}Operator".constantize
end
|