Sha256: 1599e8ae9a9f099bb4505f977a61fcd01e28c6cb20b32fec4b0fb83331184214
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
module Skr::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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stockor-core-0.2 | lib/skr/concerns/export_join_tables.rb |