lib/rom/sql/relation.rb in rom-sql-1.0.0.beta2 vs lib/rom/sql/relation.rb in rom-sql-1.0.0.beta3

- old
+ new

@@ -1,10 +1,11 @@ require 'rom/sql/types' require 'rom/sql/schema' require 'rom/sql/relation/reading' require 'rom/sql/relation/writing' +require 'rom/sql/relation/sequel_api' require 'rom/plugins/relation/key_inference' require 'rom/plugins/relation/sql/auto_combine' require 'rom/plugins/relation/sql/auto_wrap' @@ -85,9 +86,26 @@ names = db.respond_to?(:primary_key) ? Array(db.primary_key(table)) : [:id] names.map { |col| :"#{table}__#{col}" } end option :primary_key, reader: true, default: -> rel { rel.schema.primary_key_name } + + # Return relation that will load associated tuples of this relation + # + # This method is useful for defining custom relation views for relation + # composition when you want to enhance default association query + # + # @example + # assoc(:tasks).where(tasks[:title] => "Task One") + # + # @param [Symbol] name The association name + # + # @return [Relation] + # + # @api public + def assoc(name) + associations[name].(__registry__) + end # Return raw column names # # @return [Array<Symbol>] #