Module: Sequel::Plugins::ManyThroughMany::ClassMethods
- Defined in:
- lib/sequel/plugins/many_through_many.rb
Instance Method Summary collapse
- 
  
    
      #many_through_many(name, through, opts = OPTS, &block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Create a many_through_many association. 
- 
  
    
      #one_through_many(name, through, opts = OPTS, &block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Creates a one_through_many association. 
Instance Method Details
#many_through_many(name, through, opts = OPTS, &block) ⇒ Object
Create a many_through_many association. Arguments:
- name
- 
Same as associate, the name of the association. 
- through
- 
The tables and keys to join between the current table and the associated table. Must be an array, with elements that are either 3 element arrays, or hashes with keys :table, :left, and :right. The required entries in the array/hash are: - :table (first array element)
- 
The name of the table to join. 
- :left (middle array element)
- 
The key joining the table to the previous table. Can use an array of symbols for a composite key association. 
- :right (last array element)
- 
The key joining the table to the next table. Can use an array of symbols for a composite key association. 
 If a hash is provided, the following keys are respected when using eager_graph: - :db
- 
The Database containing the table. This changes lookup to use a separate query for each join table. 
- :block
- 
A proc to use as the block argument to join. 
- :conditions
- 
Extra conditions to add to the JOIN ON clause. Must be a hash or array of two pairs. 
- :join_type
- 
The join type to use for the join, defaults to :left_outer. 
- :only_conditions
- 
Conditions to use for the join instead of the ones specified by the keys. 
 
- opts
- 
The options for the associaion. Takes the same options as many_to_many. 
| 226 227 228 | # File 'lib/sequel/plugins/many_through_many.rb', line 226 def many_through_many(name, through, opts=OPTS, &block) associate(:many_through_many, name, opts.merge(through.is_a?(Hash) ? through : {:through=>through}), &block) end | 
#one_through_many(name, through, opts = OPTS, &block) ⇒ Object
Creates a one_through_many association. See many_through_many for arguments.
| 231 232 233 | # File 'lib/sequel/plugins/many_through_many.rb', line 231 def one_through_many(name, through, opts=OPTS, &block) associate(:one_through_many, name, opts.merge(through.is_a?(Hash) ? through : {:through=>through}), &block) end |