app/models/assay.rb
def associate(asset, options = {})
    if asset.is_a?(Organism)
      associate_organism(asset)
    else
      assay_asset = assay_assets.detect {|aa| aa.asset == asset}

      if assay_asset.nil?
        assay_asset = AssayAsset.new
        assay_asset.assay = self
      end

      assay_asset.asset = asset
      assay_asset.version = asset.version if asset && asset.respond_to?(:version)
      r_type = options.delete(:relationship)
      assay_asset.relationship_type = r_type unless r_type.nil?

      direction = options.delete(:direction)
      assay_asset.direction = direction unless direction.nil?
      assay_asset.save if assay_asset.changed?

      @pending_related_assets ||= []
      @pending_related_assets << asset

      return assay_asset
    end
  end
#Create or update relationship of this assay to another, with a specific relationship type and version
Create or update relationship of this assay to another, with a specific relationship type and version
Create or update relationship of this assay to another with a specific relationship type and version
def associate(asset, options = {})
    if asset.is_a?(Organism)
      associate_organism(asset)
    else
      assay_asset = assay_assets.detect {|aa| aa.asset == asset}
      if assay_asset.nil?
        assay_asset = AssayAsset.new
        assay_asset.assay = self
      end
      assay_asset.asset = asset
      assay_asset.version = asset.version if asset && asset.respond_to?(:version)
      r_type = options.delete(:relationship)
      assay_asset.relationship_type = r_type unless r_type.nil?
      direction = options.delete(:direction)
      assay_asset.direction = direction unless direction.nil?
      assay_asset.save if assay_asset.changed?
      @pending_related_assets ||= []
      @pending_related_assets << asset
      return assay_asset
    end
  end
def associate ( asset , options = { } ) if asset . is_a? ( Organism ) associate_organism ( asset ) else assay_asset = assay_assets . detect { | aa | aa . asset == asset } if assay_asset . nil? assay_asset = AssayAsset . new assay_asset . assay = self end assay_asset . asset = asset assay_asset . version = asset . version if asset && asset . respond_to? ( :version ) r_type = options . delete ( :relationship ) assay_asset . relationship_type = r_type unless r_type . nil? direction = options . delete ( :direction ) assay_asset . direction = direction unless direction . nil? assay_asset . save if assay_asset . changed? @pending_related_assets ||= [ ] @pending_related_assets << asset return assay_asset end end
Create or update relationship of this assay to another, with a specific relationship type and version
Create or update relationship of this assay to another with a specific relationship type and version
asset
options