initialize_association :belongs_to, :contact
354867
def initialize_association(type, association, opts={})
      raise 'Illegal or unimplemented association type.' unless [:belongs_to].include?(type.to_s.to_sym)
      send type, association, opts if reflect_on_association(association).nil?
    end
846802
def define_associations   
      [:has_one, :has_many, :belongs_to].each do |relation|
        if @configuration.keys.include? :"#{relation}"
          raise "Invalid #{relation} value" if not [Hash, Array, Symbol].include? @configuration[:"#{relation}"].class
          # We nee an array of models, then, we 
          if @configuration[:"#{relation}"].kind_of? Hash
            list_models = @configuration[:"#{relation}"].keys
          elsif @configuration[:"#{relation}"].kind_of? Array
            list_models = @configuration[:"#{relation}"]
          else
            list_models = [@configuration[:"#{relation}"]]
          end
          list_models.each do |model|
              meta_def model.to_s do |force_reload=false|
                if @configuration[:"#{relation}"].kind_of? Hash
                  config = @configuration[:"#{relation}"][model]
                else
                  config = {}
                end
                eval "@model_manager.read_#{relation} model, config, force_reload"
              end

            if "#{relation}" != "has_many"
              meta_def "#{model.to_s}=" do |associate|
                if @configuration[:"#{relation}"].kind_of? Hash
                  config = @configuration[:"#{relation}"][model]
                else
                  config = {}
                end
                eval "@model_manager.write_#{relation} model, @configuration[:#{relation}][model], associate"
                true
              end

              meta_def "build_#{model.to_s}" do |attributes={}|
                if @configuration[:"#{relation}"].kind_of? Hash
                  config = @configuration[:"#{relation}"][model]
                else
                  config = {}
                end
                eval "@model_manager.build_#{relation} model, config, attributes"
                true
              end

              meta_def "create_#{model.to_s}" do |attributes={}|
                if @configuration[:"#{relation}"].kind_of? Hash
                  config = @configuration[:"#{relation}"][model]
                else
                  config = {}
                end
                eval "@model_manager.create_#{relation} model, config, attributes"
                true
              end
            end
          end
        end
      end
    end
439668
def init(req, model):
    

    fields = model.all_fields
    rels = model.relationships
    params = []

    for key, val in req.params.items():
        try:
            field, oper = _parse_param(key)
        except (TypeError, ValueError):
            continue

        try:
            local_field, foreign_filter = field.split('/')
            field_type = getattr(model, local_field)

            foreign_field = field_type.field
            foreign_rtype = field_type.rtype

            if hasattr(field_type, 'local_field'):
                local_field = field_type.local_field

            param = FilterRel(foreign_field, foreign_filter, foreign_rtype,
                              local_field, field, oper, val)
        except AttributeError:
            raise InvalidQueryParams(**{
                'detail': 'The filter query param "%s" specified a filter '
                          'containing a "." indicating a relationship filter '
                          'but a relationship by that name does not exist '
                          'on the requested resource.' % key,
                'links': LINK,
                'parameter': PARAM,
            })
        except ValueError:
            param = Filter(field, oper, val)

        _validate_param(param)
        _validate_rel(param, rels)
        _validate_field(param, fields)
        params.append(param)

    return params
1068934
def db_belongs_to(name, scope = nil, **options)
      Helpers.cache_valid_method!(self)

      @database_validations_storage ||= DatabaseValidations::OptionsStorage.new(self)

      belongs_to_options =
        if ActiveRecord::VERSION::MAJOR < 5
          options.delete(:optional)
          options.merge(required: false)
        else
          options.merge(optional: true)
        end

      belongs_to(name, scope, belongs_to_options)

      foreign_key = reflections[name.to_s].foreign_key

      @database_validations_storage.push_belongs_to(foreign_key, name)

      validates_with DatabaseValidations::DBPresenceValidator,
                     DatabaseValidations::BelongsToOptions.validator_options(name, foreign_key)

      include(DatabaseValidations::Rescuer)
    end
677679
def build(associations, base_klass)
      associations.map do |name, right|
        if name.is_a? Join
          reflection = find_reflection base_klass, name.name
          reflection.check_validity!
          reflection.check_eager_loadable!

          klass = if reflection.polymorphic?
            name.klass || base_klass
          else
            reflection.klass
          end
          JoinAssociation.new(reflection, build(right, klass), alias_tracker, name.klass, name.type)
        else
          reflection = find_reflection base_klass, name
          reflection.check_validity!
          reflection.check_eager_loadable!

          if reflection.polymorphic?
            raise ActiveRecord::EagerLoadPolymorphicError.new(reflection)
          end
          JoinAssociation.new(reflection, build(right, reflection.klass), alias_tracker)
        end
      end
    end
510470
def _init_associations(fin_anno, taxid=None, taxids=None):
        """"""
        return InitAssc(taxid, taxids).init_associations(fin_anno, taxids)
860223
def load_relationship(name)
      populate_relationship(:parent, interface.parent)
      populate_relationship(:machine, interface.machine)
      populate_relationship(:children, interface.children)
    end
1299527
def initialize_metal
      Rails::Rack::Metal.requested_metals = configuration.metals
      Rails::Rack::Metal.metal_paths = ["#{TRUSTY_CMS_ROOT}/app/metal"] # reset Rails default to TRUSTY_CMS_ROOT
      Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths
      Rails::Rack::Metal.metal_paths += extension_loader.paths(:metal)
      Rails::Rack::Metal.metal_paths.uniq!

      configuration.middleware.insert_before(
        :"ActionController::ParamsParser",
        Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?)
    end
239844
public function initRelation()
    {
        // Turn models into nodes
        $this->start = $this->asNode($this->parent);
        $this->hyper = $this->asNode($this->related);
        $this->end   = $this->asNode($this->morph);

        // Not a unique relationship since it involves multiple models.
        $unique = false;

        // Setup left and right edges
        $this->left  = new EdgeOut($this->query, $this->parent, $this->related, $this->type, $this->attributes, $unique);
        $this->right = new EdgeOut($this->query, $this->related, $this->morph, $this->morphType, $this->attributes, $unique);
        // Set the morph type to the relationship so that we know who we're talking to.
        $this->right->morph_type = get_class($this->morph);
    }
407569
def model_with_associations(name)
      model = created_model(name)
      return nil unless model
      OData::PickleAdapter.get_model(model.class, model.id, true)
    end
509867
def singleton_belongs_to(*symbols, &block)
        options = symbols.extract_options!
        options.merge!(singleton: true)
        belongs_to(*symbols, options, &block)
      end
290102
def build_record
      record = model.new
      record.send("#{parent_association.name}=", parent_record) if parent_record
      record.build_defaults if record.respond_to?(:build_defaults)
      record
    end
92142
public function init ()
	{

		if (!empty($this->belongs_to)) {
			try {
				$model = $this->belongs_to['model'];
				$this->parent_model = $model::find($this->params[$this->belongs_to['param']]);

			} catch (\PDOException $e) {
				return $this->http_status(404);
			}
		}

		return parent::init();
	}
274124
def initialize_attributes(attributes)
      @_attributes = attributes
      attributes.each do |key, value|
        send("#{key}=", value) if respond_to? key
      end
    end
913850
def node(name)
      assoc = associations[name]
      other = assoc.node
      other.eager_load(assoc)
    end
323387
private void initContactSet() {

		// Initialise an array of atoms
		atoms = new Atom[groups.length];
		// Remake this local var
		indResMap = new HashMap<>();
		for (int i=0 ; i < groups.length ; i++){
			SecStrucGroup one = groups[i];
			indResMap.put(one.getResidueNumber(), i);
			atoms[i] = one.getCA();
		}
		Grid grid = new Grid(CA_MIN_DIST);
		if(atoms.length==0){
			contactSet = new AtomContactSet(CA_MIN_DIST);
		}
		else{
			grid.addAtoms(atoms);
			contactSet = grid.getAtomContacts();
		}
	}
5735
def ensure_valid_associated_record(association)
      value = send(association)
      predicate = :"#{association}?"

      if !value.class.respond_to?(predicate) || !value.class.send(predicate)
        errors.add association, I18n.t(:invalid, scope: [:errors, :messages])
      end
    end