Sha256: e9089ce3817dfebe46db1ac76a93b6798463bcfaba9db5503c8dff1621517f71
Contents?: true
Size: 1.26 KB
Versions: 9
Compression:
Stored size: 1.26 KB
Contents
module Hippo::Concerns module ExportJoinTables extend ActiveSupport::Concern included do class_attribute :exported_join_tables end module ClassMethods # Mark a joined table as safe to be included in a query # Primarily used for joining a model to a view for access to summarized data def export_join_tables( *tables ) include ExportedLimitEvaluator self.exported_join_tables ||= [] tables.flatten! options = tables.extract_options! tables.each do | join_name | self.exported_join_tables << { name: join_name, limit: options[:limit] } end end # Has the join been marked as safe? def has_exported_join_table?(name, user) return true if name == 'details' # "details" is reserved for views and is always allowed self.exported_join_tables && self.exported_join_tables.detect{ | join | join[:name] == name && evaluate_export_limit( user, :join, join[:name], join[:limit] ) } end end end end
Version data entries
9 entries across 9 versions & 1 rubygems