Giter Club home page Giter Club logo

ensconce's Introduction

ensconce

Ensconce provides a common interface to data stores. The connection between Ensconce::DataStore and a data store provider is configured via an adapter

YAML file data store

user = User.new(:id => 'user_1')
DataStore.adapter = YamlFileAdapter.config(:file => 'path/to/file.yml')
data_store = DataStore.open user

Opens a data store from the file specified within the adapter config. The store could look something like this:

user_1:
  some_field: x

We can get and set ‘some_field’ like this

data_store['some_field'] == 'x'   # returns true
data_store['some_field'] = 'y'
data_store.save

The file will then look like this:

user_1:
  some_field: y

Mydex data source

DataStore.adapter = MydexAdapter.config(
  url: <mydex url>
  api_key: <your api key>
)

user = MydexUser.new(
  key: <from your user's connection settings>
  con_id: <from your user's connection settings>
  id: <from your user's connection settings>
)

settings.yml is provided as a place where you can enter valid sandbox setting, and these will be used when testing. The test connection needs access to the sandbox user’s personal_details area.

We can then get the mydex user’s data like this:

data_store = DataStore.open(user, :data_set => 'field_ds_personal_details')
data_store['first_name'] --> Mydex user's first name

Updating data works just as it does for the YAML example:

data_store['first_name'] = 'Robert'
data_store.save

This will write a new first name to the Mydex user’s personal_details.

Key mappers

Note that in Mydex the first name field is actually ‘field_personal_fname’. Ensconce provides key mappers that allow you to use more generic names for fields, thereby making it easier to swap data stores.

ensconce's People

Contributors

reggieb avatar

Watchers

 avatar  avatar

Forkers

mrchrisadams

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.