You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ds_doc_wrapper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ds_doc_wrapper

1.2.3
bundlerRubygems
Version published
Maintainers
1
Created
Source

= DocWrapper

This project rocks and uses MIT-LICENSE.

== Description

Doc wrapper, convert a doc in another doc. Doc is some ruby data structure, like a Hash, Array or a simple String

The advantage is that the conversion engine is automatically identified, making the code cleaner

===== Example

:001 > DocWrapper.to_target_doc {origin: :sales, user_id: 1, account_id: 99 }
=> { user: 'John', account_name: 'xxxx' }

another example, only changes de origin key :002 > DocWrapper.to_target_doc {owner: :billing, user_id: 1, account_id: 99 } ==> { user_name: 'john', amount: 100.87 }

== Install

$ gem install ds_doc_wrapper

== Usage

First you need define some doc wrappers

class DocWrapper::DocByTomCat def self.to_target_doc a_doc # -- here put you converter code { tom_cat_name: a_doc['name'], tom_cat_eat: a_doc['food'] } end end

another doc wrapper:

class DocWrapper::DocByCook def self.to_target_doc a_doc # -- here put you converter code { name: a_doc['name'], main: a_doc['food'] } end end

them: :003 > DocWrapper::Base.to_target_doc( { owner: 'tom_cat', 'name' => 'Tom', 'food' => 'fish' } ) ==> { tom_cat_name: 'Tom', tom_cat_eat: 'fish' }

:004 >  DocWrapper::Base.to_target_doc( { owner: 'cook', 'name' => 'Tom', 'food' => 'fish' } )
==> { name: 'Tom', main: 'fish' }

== Change log

  • 1.2 -> Add ds_hash dependency
  • 1.1 -> Add default options configurations

FAQs

Package last updated on 20 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts