Creates methods on from_owner to call through to methods on to_owner.

  :from_owner: the object to delegate to
  :to_owner: the owner on which to delegate from
  :methods: a list of methods to delegate
422110
def delegate(from_owner, to_owner, methods):
  
  for method in methods:
    _delegate(from_owner, to_owner, method)
621015
def ownership(self, ownership):
        
        error_msg = 'ownership must be a list of dictionaries'
        if ownership:
            if not isinstance(ownership, list):
                raise TypeError(error_msg)
            if not all([isinstance(item, dict) for item in ownership]):
                raise TypeError(error_msg)
            if not all([item.get('party_id') for item in ownership]):
                raise ValueError('Ownership missing one or more party_ids')
            if not all([item.get('split') for item in ownership]):
                raise ValueError('Ownership missing one or more splits')
            if sum([item.get('split') for item in ownership]) != Decimal('1'):
                raise ValueError('Ownership must sum up to 100%')
        self._ownership = ownership
11329
private function initDelegates()
    {
        // start event dispatching
        $this->eventDispatcher = new EventDispatcher;
        
        // create operator
        $this->operator = $this->getCollection()->operator();

        // attach behaviors
        $this->attachBehaviors($this->behaviors());
        if ($this->hasOption('behaviors')) {
            $this->attachBehaviors($this->getOption('behaviors'));
        }
    }
739240
def delegate_via(accessor_name, *method_names, &return_block)
      options    = method_names.last.is_a?(Hash) ? method_names.pop : {}
      via_method = options.fetch(:via, :map)

      mod = if const_defined?(:DelegateVia, false)
              const_get(:DelegateVia)
            else
              new_mod = Module.new do
                def self.to_s
                  "DelegateVia(#{instance_methods(false).join(', ')})"
                end
              end
              const_set(:DelegateVia, new_mod)
            end

      mod.module_eval do
        method_names.each do |method_name|
          define_method method_name do |*args, &block|
            accessor = __send__(accessor_name)
            result   = accessor.__send__(via_method) { |service| service.__send__(method_name, *args, &block) }
            return_block ? instance_exec(result, &return_block) : result
          end
        end
      end
      include mod
    end
1336458
def define_methods_into(client)
      links.each do |link|
        @client.define_singleton_method(link.method_signature) do |params = {}, headers = {}|
          Request.call(client: client, headers: headers, link: link, params: params)
        end
      end
    end
1092204
def orderered_methods(self):
        

        oms = []

        self.methods.reverse()

        if self.main:
            oms = [self.main]

        for m in self.methods:

            if m == self.main:
                continue
            oms.append(m)

        return oms
13903
def poor_mans_method_owner(method, method_name)
      # A Method object has no :owner method, but we can infer it's owner from the result of it's
      # :to_s method. Examples:
      # 37.method(:rdiv).to_s => "#<Method: Fixnum#rdiv>"
      # 37.method(:ceil).to_s => "#<Method: Fixnum(Integer)#ceil>"
      # 37.method(:prec).to_s => "#<Method: Fixnum(Precision)#prec>"
      # obj.method(:singleton_method).to_s => "#<Method: #<Object:0x5673b8>.singleton_method>"
      # For a nested module: "#<Method: Module1::ClassName(Module1::Module2::Module3)#method>"

      build_ancestor_regexp_map
      @ancestors.each do |ancestor|
        return ancestor if method.to_s =~ @ancestor_regexp_map[ancestor]
      end
      nil
    end
683663
def context(&block)
      # Include the context
      context = @context
      machine.owner_class.class_eval { include context }
      
      # Evaluate the method definitions and track which ones were added
      old_methods = context_methods
      context.class_eval(&block)
      new_methods = context_methods.to_a.select {|(name, method)| old_methods[name] != method}
      
      # Alias new methods so that the only execute when the object is in this state
      new_methods.each do |(method_name, method)|
        context_name = context_name_for(method_name)
        context.class_eval <<-end_eval, __FILE__, __LINE__ + 1
          alias_method :"#{context_name}", :#{method_name}
          def #{method_name}(*args, &block)
            state = self.class.state_machine(#{machine.name.inspect}).states.fetch(#{name.inspect})
            options = {:method_missing => lambda {super(*args, &block)}, :method_name => #{method_name.inspect}}
            state.call(self, :"#{context_name}", *(args + [options]), &block)
          end
        end_eval
      end
      
      true
    end
357640
def create_method(self):
        
        n_indents = 1 if self.target_language in ['java', 'js',
                                                  'php', 'ruby'] else 0
        return self.temp('separated.method', n_indents=n_indents,
                         skipping=True).format(**self.__dict__)
1120216
def delegate_to_model(method, *args, &block)
      model = self.model
      model.send(:with_scope, query) do
        model.send(method, *args, &block)
      end
    end
420680
def methodcaller(name, *args):
    
    func = operator.methodcaller(name, *args)
    return lambda obj, **kwargs: func(obj)
71911
def create_protocol(self):
        
        self.sessions += 1
        protocol = self.protocol_factory(self)
        protocol.copy_many_times_events(self)
        return protocol
628705
def create_connection(self, from_obj, to_obj):
        
        self._validate_ctypes(from_obj, to_obj)
        return Connection.objects.get_or_create(relationship_name=self.name,
                                                from_pk=from_obj.pk, to_pk=to_obj.pk)[0]
1230708
def bind(self, container, method_name):
        
        instance = super(Entrypoint, self).bind(container)
        instance.method_name = method_name
        return instance
857191
def delegate_to_property(aliaz, property)
      ra, wa = property.accessors
      if aliaz == ra then raise MetadataError.new("Cannot delegate #{self} #{aliaz} to itself.") end
      define_method(aliaz) { send(ra) }
      define_method("#{aliaz}=".to_sym) { |value| send(wa, value) }
      register_property_alias(aliaz, property.attribute)
    end
943047
def owner(self, owner):
        
        if owner is None:
            raise ValueError("Invalid value for `owner`, must not be `None`")
        if owner is not None and len(owner) > 31:
            raise ValueError("Invalid value for `owner`, length must be less than or equal to `31`")
        if owner is not None and len(owner) < 3:
            raise ValueError("Invalid value for `owner`, length must be greater than or equal to `3`")
        if owner is not None and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', owner):
            raise ValueError("Invalid value for `owner`, must be a follow pattern or equal to `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`")

        self._owner = owner
102003
def link_methods(self):
        

        from ..compiler import Compiler

        for method in self.methods:
            method.prepare()

        self.all_vm_tokens = OrderedDict()

        address = 0

        for method in self.orderered_methods:

            if not method.is_interop:
                #                print("ADDING METHOD %s " % method.full_name)
                method.address = address

                for key, vmtoken in method.vm_tokens.items():
                    self.all_vm_tokens[address] = vmtoken
                    address += 1

                    if vmtoken.data is not None and vmtoken.vm_op != VMOp.NOP:
                        address += len(vmtoken.data)

                    vmtoken.addr = vmtoken.addr + method.address

        for key, vmtoken in self.all_vm_tokens.items():
            if vmtoken.src_method is not None:

                target_method = self.method_by_name(vmtoken.target_method)
                if target_method:
                    jump_len = target_method.address - vmtoken.addr

                    param_ret_counts = bytearray()
                    if Compiler.instance().nep8:
                        param_ret_counts = vmtoken.data[0:2]
                        jump_len -= 2

                    if jump_len > -32767 and jump_len < 32767:
                        vmtoken.data = param_ret_counts + jump_len.to_bytes(2, 'little', signed=True)
                    else:
                        vmtoken.data = param_ret_counts + jump_len.to_bytes(4, 'little', signed=True)
                else:
                    raise Exception("Target method %s not found" % vmtoken.target_method)