Skip to main content
# privatebroker

PrivateBroker (beta) is a module for encapsulation.

It allows you to hide methods of classes that are undesirable in the implementation of child elements. Private methods become unavailable in instances of classes and classes of heirs.

Private methods are kept in the "broker", which allows you to access the private method if necessary.

## Installation

Use the package manager [pip](https://pip.pypa.io/...) to install foobar.

```bash
pip install privatebroker
```

## Usage

the privateclass decorator accepts a class whose specific methods must be hidden. the decorator privatemethod accepts the method and puts it in the broker.

The broker returns the necessary function (attribute of the private method) by taking two arguments: the class (from example A (!! not self !!)) and the name of the method (the string is required).

To get the result of a private method, you need to refer to the attribute of the private method and pass it the arguments expected by the private method.

```python

from privatebroker import privateclass, privatemethod

@privateclass
class A(object):

def __init__(self, *args, **kwargs):
self.some_one = {}


@privatemethod
def a_private2(self):
pass


@privatemethod
def a_private(self, key, value):
self.some_one[key] = value


def test(self, x, y):
private = self.broker(A, 'a_private') # call to private
return private(self, x, y)


def a_public(self):
return self.some_one

#a = A()
#print(a.a_private()) - > Error

@privateclass
class B(A):

@privatemethod
def b_private(self):
return 'Я могу быть только у объекта B'

def b_public(self):
self.test('a', 11)
return self.some_one


b = B()
print(b.b_public())
```

## Contributing

Important!
This is the first test version and so far the expediency of using this module is questionable!
Traction requests are welcome. For major changes, please first open the question to discuss
what you would like to change.

Please remember to update the tests as needed.

## License
[MIT](https://choosealicense.com/licenses/mit/)

Metadata

Release files for privatebroker 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for privatebroker 0.0.1
File Size Uploaded
privatebroker-0.0.1.tar.gz 3.1 kB Details

Release files / privatebroker-0.0.1.tar.gz

Download URL privatebroker-0.0.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8e65922ab8f92ddda5e8e456e192b257323f317f58c40954fd26166c64ea9138
BLAKE2b-256 checksum
How to use checksums
a9cf12befca3619368898d3c942212e1300de9cc729aa2ab9766c84e9a8e662f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page