app/models/run.rb
# find generally associated entitie(s) as attribute of an entity instance(self)
# if top of args is a symbol, it is assoc_name which is different from target_modle_name.to_assoc_name.
find generally associated entitie(s) as attribute of an entity instance(self)
if top of args is a symbol, it is assoc_name which is different from target_modle_name.to_assoc_name.
find generally associated entitie ( s ) as attribute of an entity instance ( self ) if top of args is a symbol it is assoc_name which is different from target_modle_name . to_assoc_name .
def association(target_model_name, assoc_net, assoc_target_type, *args)
    assoc_name = args.first.is_a?(Symbol) ? args.shift.to_s : nil
    options = Run.get_options_from_args!(args).to_h.dup 
    options[:scope] =  assoc_scope(assoc_net)
    collection = [] 
    assoc = new_assoc(collection, target_model_name, assoc_net, assoc_target_type, assoc_name)
    if new_record?   
      connection_conds = connection_conditions_from(assoc.connection_factors)
      unless connection_conds.blank? 
        options[:conditions] = Run.merge_conditions(options[:conditions].to_a, *connection_conds) 
        collection +=  assoc.target_model.find(:all, *(args << options)).to_a
      end
    else  
      connection_cond =  "#{Self_Entity}.run_id = #{self.run_id}"
      options[:conditions] = Run.merge_conditions(options[:conditions], connection_cond)
      collection +=  assoc.target_model.find(:all, *(args << options)).to_a
    end
    Association.new(collection).move_assoc_attrs_from!(assoc)
  end
def association ( target_model_name , assoc_net , assoc_target_type , * args ) assoc_name = args . first . is_a? ( Symbol ) ? args . shift . to_s : nil options = Run . get_options_from_args! ( args ) . to_h . dup options [ :scope ] = assoc_scope ( assoc_net ) collection = [ ] assoc = new_assoc ( collection , target_model_name , assoc_net , assoc_target_type , assoc_name ) if new_record? connection_conds = connection_conditions_from ( assoc . connection_factors ) unless connection_conds . blank? options [ :conditions ] = Run . merge_conditions ( options [ :conditions ] . to_a , * connection_conds ) collection += assoc . target_model . find ( :all , * ( args << options ) ) . to_a end else connection_cond = "#{Self_Entity}.run_id = #{self.run_id}" options [ :conditions ] = Run . merge_conditions ( options [ :conditions ] , connection_cond ) collection += assoc . target_model . find ( :all , * ( args << options ) ) . to_a end Association . new ( collection ) . move_assoc_attrs_from! ( assoc ) end
find generally associated entitie(s) as attribute of an entity instance(self)
if top of args is a symbol, it is assoc_name which is different from target_modle_name.to_assoc_name.
find generally associated entitie ( s ) as attribute of an entity instance ( self ) if top of args is a symbol it is assoc_name which is different from target_modle_name . to_assoc_name .
# assoc_entity is not recorded(saved) yet # self has been saved.
target_model_name
<not_specific>
assoc_net
<not_specific>
assoc_target_type
<not_specific>
args
<not_specific>