Code Monkey home page Code Monkey logo

abra's Introduction

Abra

image

Abra is a work in progress framework. In the current version only the cache module is available. It will be released over Cocoapods at a later stage.

#Spec

Overview: Abra is a library that aim to simplify the backend/model layer of your application if you use a RESTful API. The end goal is that you should be able to have a working model layer mapped to your API without the need to write any line of code. The only things you'll need is to create your models and add your properties inside. Then you'll be able to do GET/POST/PUT/PATCH/DELETE against any of your model and it will return a correctly initialised instance. (It'll supports arrays of models + nested models)

Abra is built over already existing libraries, it combine the power of Mantle (JSON automatic parsing and more) and AFNetworking (Network) and wrap them in something even simpler.

Abra is a framework built around 3 modules

##ABModel

ABModel is the Abra most important component. All your models that you want to map to some REST path/call should inherit of ABModel As Abra is built around Mantle, it will support any feature you want from it. I invite you to have a look here.

+ (NSDictionary *)JSONKeyPathsByPropertyKey Especially you should implement this method from Mantle if you JSON response have different properties name than your local models.

ABModel will automatically generate the needed NSValueTransformer for your nested models at runtime. But you are in charge to implement your own value transformers if you need to do some operation in some of the values of your JSON response. (NSDate transformation, etc...)

##ABCache

ABCache is a singleton which Abra use for both in memory cache and disk cache. Models are cached on disk using <NSCoder> (which is automatically implemented by Mantle). You don't need to use ABCache directly, it is used by ABAPI when you do a GET request. ABCache allow Abra to return to you both the cached response (from the in memory store or disk) and then the new response from the API call. And then it'll automatically cache the new response.

You can look at the header for a more in depth look of the available methods. You can use it as a standalone module if you want.

Each models that inherit ABModel will provide their GET/POST/PUT/PATCH/DELETE methods, with some variation if you want to do some custom parsing. The idea is that the only thing to do is to call this method

- (void)getForPath:(NSString *)path
        completion:(void(^)(BOOL success, BOOL cached, instanceOrArrayOfInstance))completion;

A lot of variations of those methods will exist (With parameters, will multiple return block etc..).

###Transformations generated at runtime #####NSURL #####Nested model that inherit from ABModel

##ABAPI

ABAPI is a subclass of AFHTTPSessionManager and provide some useful and Abra specific helpers. You don't need to use this class directly, the only required things to do is to call the setupWithBaseURL: method before attempting any model call. This class is in charge of the API call/Cache mechanism and logic. ABModel use it extensively.

abra's People

Contributors

dimillian avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.