Sha256: 218540320f6f56a654056a0212f18bda0aea3c90c56e58049b708dcf38d82dae

Contents?: true

Size: 676 Bytes

Versions: 4

Compression:

Stored size: 676 Bytes

Contents

module ActiveRecord
  module FinderMethods
    def construct_relation_for_association_find(join_dependency)
      calculated_columns = arel.projections.select { |p| p.is_a?(Arel::Nodes::Node) && p.calculated_attr? }
      relation = except(:includes, :eager_load, :preload, :select).select(join_dependency.columns.concat(calculated_columns))
      join_dependency.calculated_columns = calculated_columns
      apply_join_dependency(relation, join_dependency)
    end
  end
end

module Arel
  module Nodes
    class Node
      def calculated_attr!
        @is_calculated_attr = true
      end

      def calculated_attr?
        @is_calculated_attr
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
calculated_attributes-0.5.0 lib/calculated_attributes/rails_patches.rb
calculated_attributes-0.4.0 lib/calculated_attributes/rails_patches.rb
calculated_attributes-0.3.0 lib/calculated_attributes/rails_patches.rb
calculated_attributes-0.2.0 lib/calculated_attributes/rails_patches.rb