Module: ActiveHouse::Querying::ArrayJoin
- Extended by:
- ActiveSupport::Concern
- Included in:
- ActiveHouse::QueryBuilder
- Defined in:
- lib/active_house/querying/array_join.rb
Instance Method Summary collapse
- #array_join(*fields) ⇒ Object
- #array_join!(*fields) ⇒ Object
- #build_array_join_query_part ⇒ Object
- #initial_values ⇒ Object
- #left_array_join(*fields) ⇒ Object
- #left_array_join!(*fields) ⇒ Object
Instance Method Details
#array_join(*fields) ⇒ Object
27 28 29 |
# File 'lib/active_house/querying/array_join.rb', line 27 def array_join(*fields) dup.array_join!(*fields) end |
#array_join!(*fields) ⇒ Object
21 22 23 24 25 |
# File 'lib/active_house/querying/array_join.rb', line 21 def array_join!(*fields) formatted_fields = ActiveHouse::PreparedStatement.format_fields(model_class, fields) values[:array_join] = (values[:array_join] + formatted_fields).uniq self end |
#build_array_join_query_part ⇒ Object
10 11 12 13 14 15 |
# File 'lib/active_house/querying/array_join.rb', line 10 def build_array_join_query_part parts = [] parts << "ARRAY JOIN #{values[:array_join].join(', ')}" unless values[:array_join].empty? parts << "LEFT ARRAY JOIN #{values[:array_join].join(', ')}" unless values[:left_array_join].empty? parts.join("\n") end |
#initial_values ⇒ Object
17 18 19 |
# File 'lib/active_house/querying/array_join.rb', line 17 def initial_values super.merge array_join: [], left_array_join: [] end |
#left_array_join(*fields) ⇒ Object
37 38 39 |
# File 'lib/active_house/querying/array_join.rb', line 37 def left_array_join(*fields) dup.left_array_join!(*fields) end |
#left_array_join!(*fields) ⇒ Object
31 32 33 34 35 |
# File 'lib/active_house/querying/array_join.rb', line 31 def left_array_join!(*fields) formatted_fields = ActiveHouse::PreparedStatement.format_fields(model_class, fields) values[:left_array_join] = (values[:left_array_join] + formatted_fields).uniq self end |