Decorates AR model object's association only when the object was decorated.
 Returns the association instance.
496173
def decorate_association(owner, target)
      owner.is_a?(ActiveDecorator::Decorated) ? decorate(target) : target
    end
1096107
def clone_has_one(old_object, new_object)
      old_object.class.reflect_on_all_associations(:has_one).each do |association|
        old_association = old_object.send(association.name)
        build_has_one(new_object, association, old_association) if build_has_one?(old_object, association)
      end

      new_object
    end
1351193
def fetch_association(name, includes=nil)
      association = fetch_property(name)

      if includes.present? && ! @resource.association(name).loaded?
        association.includes(includes)
      else
        association
      end
    end
907451
def awesome_mongo_mapper_association(object)
      return object.inspect if !defined?(::ActiveSupport::OrderedHash)
      return awesome_object(object) if @options[:raw]

      association = object.class.name.split('::').last.titleize.downcase.sub(/ association$/, '')
      association = "embeds #{association}" if object.embeddable?
      class_name = object.class_name

      "#{colorize(association, :assoc)} #{colorize(class_name, :class)}"
    end
572501
def save_bt_association(assoc, version)
      assoc_version_args = {
        version_id: version.id,
        foreign_key_name: assoc.foreign_key
      }

      if assoc.options[:polymorphic]
        foreign_type = @record.send(assoc.foreign_type)
        if foreign_type && ::PaperTrail.request.enabled_for_model?(foreign_type.constantize)
          assoc_version_args[:foreign_key_id] = @record.send(assoc.foreign_key)
          assoc_version_args[:foreign_type] = foreign_type
        end
      elsif ::PaperTrail.request.enabled_for_model?(assoc.klass)
        assoc_version_args[:foreign_key_id] = @record.send(assoc.foreign_key)
        assoc_version_args[:foreign_type] = assoc.klass
      end

      if assoc_version_args.key?(:foreign_key_id)
        ::PaperTrail::VersionAssociation.create(assoc_version_args)
      end
    end
309041
def save_belongs_to_association(reflection)
      association = association_instance_get(reflection.name)
      record      = association && association.load_target
      if record && !record.destroyed?
        autosave = reflection.options[:autosave]

        if autosave && record.marked_for_destruction?
          record.destroy
        elsif autosave != false
          saved = record.save(:validate => !autosave) if record.new_record? || (autosave && record.changed_for_autosave?)

          if association.updated?
            association_id = record.send(reflection.options[:primary_key] || :id)
            self[reflection.foreign_key] = association_id
            association.loaded!
          end

          saved if autosave
        end
      end
    end
628245
def update(self, **kwargs):
        
        for attr, val in kwargs.items():
            if attr in (list(self.__class__.__attributes__) + \
                        list(associations.associations_for(self.__class__))):
                setattr(self, attr, val)
428366
def set_association_id(self, assoc_id=None):
        
        if assoc_id is None:
            self.assoc_id = self.make_association_id(
                self.definedby, self.sub, self.rel, self.obj)
        else:
            self.assoc_id = assoc_id

        return self.assoc_id
1078014
def save_habtm_association?(assoc)
      @record.class.paper_trail_save_join_tables.include?(assoc.name) ||
        ::PaperTrail.request.enabled_for_model?(assoc.klass)
    end
916791
def _init_associations(self, fin_gpad, hdr_only=False):
        """"""
        ini = InitAssc(fin_gpad, self.godag)
        nts = ini.init_associations(hdr_only)
        self.hdr = ini.hdr
        return nts
569296
public function association()
    {
        //====================================================================//
        // Safety Checks ==> Verify a new Field Exists
        if (empty($this->new)) {
            Splash::log()->err("ErrFieldsNoNew");
        } else {
            //====================================================================//
            // Field Clear Fields Associations
            if (!empty($this->new->asso)) {
                $this->new->asso = null;
            }

            //====================================================================//
            // Set New Field Associations
            if (!empty(func_get_args())) {
                $this->new->asso = func_get_args();
            }
        }

        return $this;
    }
787716
def find(*args, &block)
      if block_given?
        decorated_collection.find(*args, &block)
      else
        ActiveSupport::Deprecation.warn('Using ActiveRecord\'s `find` on a CollectionDecorator is deprecated. ' +
                                        'Call `find` on a model, and then decorate the result', caller)

        decorate_item(object.find(*args))
      end
    end
1085834
def get_wrapped_instance(self, instance=None):
        
        if instance._meta.label_lower not in self.registry:
            raise ModelNotRegistered(f"{repr(instance)} is not registered with {self}.")
        wrapper_cls = self.registry.get(instance._meta.label_lower) or self.wrapper_cls
        if wrapper_cls:
            return wrapper_cls(instance)
        return instance
89387
public AssociationContext getAssociationContext() {
		if ( associationContext == null ) {
			associationContext = new AssociationContextImpl(
					associationTypeContext,
					hostingEntity != null ? OgmEntityEntryState.getStateFor( session, hostingEntity ).getTuplePointer() : new TuplePointer(),
					transactionContext( session )
			);
		}

		return associationContext;
	}
1083169
def register(self, models=None, wrapper_cls=None):
        
        self.loaded = True
        for model in models:
            model = model.lower()
            if model not in self.registry:
                self.registry.update({model: wrapper_cls or self.wrapper_cls})
                if self.register_historical:
                    historical_model = ".historical".join(model.split("."))
                    self.registry.update(
                        {historical_model: wrapper_cls or self.wrapper_cls}
                    )
            else:
                raise AlreadyRegistered(f"Model is already registered. Got {model}.")
1175547
public static Object resolveUnderlyingObject(Object obj) {
    while(obj instanceof Decorator) {
      obj = ((Decorator)obj).getDecoratedObject();
    }
    return obj;
  }
247690
def validate_single_association(reflection)
        association = association_instance_get(reflection.name)
        record      = association && association.reader
        association_valid?(reflection, record) if record
      end