A DSL method for defining a class that holds serialization logic.

 @param [Class] klass a class that should inherit form Surrealist::Serializer

 @raise ArgumentError if Surrealist::Serializer is not found in the ancestors chain
10892
def surrealize_with(klass, tag: Surrealist::VarsHelper::DEFAULT_TAG)
      if klass < Surrealist::Serializer
        Surrealist::VarsHelper.add_serializer(self, klass, tag: tag)
        instance_variable_set(VarsHelper::PARENT_VARIABLE, klass.defined_schema)
      else
        raise ArgumentError, "#{klass} should be inherited from Surrealist::Serializer"
      end
    end
824708
function (klass) {
      var view = _emberMetalProperty_get.get(this, 'parentView');
      var isOfType = klass instanceof _emberMetalMixin.Mixin ? function (view) {
        return klass.detect(view);
      } : function (view) {
        return klass.detect(view.constructor);
      };

      while (view) {
        if (isOfType(view)) {
          return view;
        }
        view = _emberMetalProperty_get.get(view, 'parentView');
      }
    }
1331870
def klass_from_predicate(predicate)
      field_name = field_from_predicate(predicate)
      return unless field_name

      relation = relations[field_name]
      return unless relation

      relation.class_name.constantize
    end
680485
def serializer_class(self):
        
        serializer_class = self._serializer_class
        if not isinstance(serializer_class, six.string_types):
            return serializer_class

        parts = serializer_class.split('.')
        module_path = '.'.join(parts[:-1])
        if not module_path:
            if getattr(self, 'parent', None) is None:
                raise Exception(
                    "Can not load serializer '%s'" % serializer_class +
                    ' before binding or without specifying full path')

            # try the module of the parent class
            module_path = self.parent.__module__

        module = importlib.import_module(module_path)
        serializer_class = getattr(module, parts[-1])

        self._serializer_class = serializer_class
        return serializer_class
1358655
def call(definition, klass)
      variable = definition.instance_variable

      klass.instance_eval do
        define_method(definition.reader) { instance_variable_get(variable) }
      end
    end
752969
def instantiate(self, cls=None):
        
        if cls is None:
            cls = self.cls
        if cls is None:
            raise TypeError("cls must a class")
        return cls.create(*self.args, **self.kwargs)
597282
def __deserialize_model(self, data, klass):
        
        if not klass.swagger_types:
            return data

        kwargs = {}
        for attr, attr_type in iteritems(klass.swagger_types):
            if data is not None \
               and klass.attribute_map[attr] in data \
               and isinstance(data, (list, dict)):
                value = data[klass.attribute_map[attr]]
                kwargs[attr] = self.__deserialize(value, attr_type)

        instance = klass(**kwargs)     

        return instance
1266327
def klass_for_type(type, singular=false)
      type = type.singularize unless singular
      type.classify.constantize
    end
865837
def _class_type(klass, ancestors=None):
    
    # XXX we have to store ancestors in case we have an ancestor loop
    if klass._type is not None:
        return klass._type
    if _is_metaclass(klass):
        klass._type = "metaclass"
    elif klass.name.endswith("Exception"):
        klass._type = "exception"
    else:
        if ancestors is None:
            ancestors = set()
        klass_name = klass.qname()
        if klass_name in ancestors:
            # XXX we are in loop ancestors, and have found no type
            klass._type = "class"
            return "class"
        ancestors.add(klass_name)
        for base in klass.ancestors(recurs=False):
            name = _class_type(base, ancestors)
            if name != "class":
                if name == "metaclass" and not _is_metaclass(klass):
                    # don't propagate it if the current class
                    # can't be a metaclass
                    continue
                klass._type = base.type
                break
    if klass._type is None:
        klass._type = "class"
    return klass._type
431397
public static <F extends Fragment> FragmentBundler<F> create(Class<F> klass) {
    try {
      return create(klass.newInstance());
    } catch (InstantiationException e) {
      throw new IllegalArgumentException("Class must have a no-arguments constructor.");
    } catch (IllegalAccessException e) {
      throw new IllegalArgumentException("Class must have a no-arguments constructor.");
    }
  }
723908
def check_class(klass)
      unless klass.method_defined?(name)
        raise NotImplementedErrorCheckError.new(self,
            "method '#{name}' not implemented in #{klass}")
      end
      check_method = klass.instance_method(name)
      if arity and (check_arity = check_method.arity) != arity
        raise ArgumentErrorCheckError.new(self,
              "wrong number of arguments for protocol"\
              " in method '#{name}' (#{check_arity} for #{arity}) of #{klass}")
      end
      if block_expected?
        modul = Utilities.find_method_module(name, klass.ancestors)
        parser = MethodParser.new(modul, name)
        parser.block_arg? or raise BlockCheckError.new(self,
          "expected a block argument for #{klass}")
      end
      arity and wrap_method(klass)
      true
    end
94056
def get_serializer(self, *args, **kwargs):
        
        serializer_class = self.get_serializer_class()
        kwargs['context'] = self.get_serializer_context()
        return serializer_class(*args, **kwargs)
1364968
def get_class_alias(klass):
    
    for k, v in pyamf.ALIAS_TYPES.iteritems():
        for kl in v:
            try:
                if issubclass(klass, kl):
                    return k
            except TypeError:
                # not a class
                if hasattr(kl, '__call__'):
                    if kl(klass) is True:
                        return k
1247870
@Override
    public void visitClassDef(JCClassDecl tree) {
        if (tree.sym.owner.kind == PCK) {
            //analyze class
            tree = analyzer.analyzeAndPreprocessClass(tree);
        }
        KlassInfo prevKlassInfo = kInfo;
        try {
            kInfo = new KlassInfo(tree);
            super.visitClassDef(tree);
            if (!kInfo.deserializeCases.isEmpty()) {
                int prevPos = make.pos;
                try {
                    make.at(tree);
                    kInfo.addMethod(makeDeserializeMethod(tree.sym));
                } finally {
                    make.at(prevPos);
                }
            }
            //add all translated instance methods here
            List<JCTree> newMethods = kInfo.appendedMethodList.toList();
            tree.defs = tree.defs.appendList(newMethods);
            for (JCTree lambda : newMethods) {
                tree.sym.members().enter(((JCMethodDecl)lambda).sym);
            }
            result = tree;
        } finally {
            kInfo = prevKlassInfo;
        }
    }
860124
def deserialize(klass, data):
    
    handler = DESERIALIZE_REGISTRY.get(klass)
    if handler:
        return handler(data)
    raise TypeError("There is no deserializer registered to handle "
                    "instances of '{}'".format(klass.__name__))
595114
public void addDefaultKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) {
		config.addDefaultKryoSerializer(type, serializerClass);
	}
1143756
def factory(name, klass = nil, &block)
      @registry[name.to_sym] = Resolver::Factory.new(block || klass)
    end