module Hippo::Concerns::ExportJoinTables::ClassMethods

Public Instance Methods

export_join_tables( *tables ) click to toggle source

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

# File lib/hippo/concerns/export_join_tables.rb, line 14
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_exported_join_table?(name, user) click to toggle source

Has the join been marked as safe?

# File lib/hippo/concerns/export_join_tables.rb, line 29
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