Skip to content

What is BaseModel

Karen edited this page Feb 1, 2018 · 2 revisions

BaseModel was created for the sake of DRY. The main concept is a storage layer (or a Proxy) for some data, and a FieldSet, describes how this data will be treated before the request. A simple abstraction that provides you some special mechanisms called Fields, FieldProcessors, Modifiers and, of course, Containers

Containers

This is the "center of the Universe" :) Container represents the behavior of 1 request (ideal). It has a name, a field set and a data storage (or a Proxy, if you want to use an external source of data for this container)

Fields

Before sending any request you should specify the way your data will be treated. For this reason we have Fields. In this section you just say to a container what fields you are going to send. In particular, you are just describing a model.

FieldProcessors

When you are specifying a field set, you might also need a type for a field. I call it - Processor. It is basically how each field will be prepared before sending.

Modifiers

The last, but not least - Modifiers. It is basically how each field will be prepared before sending. Wait, what? You might say: "Hey! Haven't you been telling about Processors already?"... Well, the answer is Yes and No. Processor has some restrictions.

Processors can't:

  • get a parameter to a callback
  • stop the chain

Modifiers can manipulate the chain and modify data on the fly with some parameters.

BTW

It was helping me A LOT in my own projects on the production

Clone this wiki locally