Module: ActiveHouse::ArrayJoinable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Chainable
- Defined in:
- lib/active_house/array_joinable.rb
Instance Method Summary collapse
Instance Method Details
#array_join(*fields) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_house/array_joinable.rb', line 20 def array_join(*fields) raise ArgumentError, 'wrong number of arguments' if fields.empty? formatted_fields = fields.map do |field| if field.is_a?(Symbol) && model_class._attribute_opts.key?(field) opts = model_class._attribute_opts.fetch(field) opts.key?(:select) ? "#{opts[:select]} AS #{field}" : field.to_s else field.to_s end end chain_query array_joins: (@array_joins + formatted_fields).uniq end |
#initialize ⇒ Object
15 16 17 18 |
# File 'lib/active_house/array_joinable.rb', line 15 def initialize(*) @array_joins = [] super end |