Parcourir la source

Added section on creating an adapter

Andrew Kane il y a 7 ans
Parent
commit
d8187459e5
1 fichiers modifiés avec 22 ajouts et 1 suppressions
  1. 22 1
      README.md

+ 22 - 1
README.md

@@ -394,7 +394,7 @@ data_sources:
 - [MongoDB](#mongodb-1) [beta]
 - [Elasticsearch](#elasticsearch) [beta]
 
-You can also create an adapter for any other data store.
+You can also [create an adapter](#creating-an-adapter-master) for any other data store.
 
 **Note:** In the examples below, we recommend using environment variables for urls.
 
@@ -493,6 +493,27 @@ data_sources:
     url: http://user:password@hostname:9200/
 ```
 
+## Creating an Adapter [master]
+
+Create an adapter for any data store with:
+
+```
+class FooAdapter < Blazer::Adapters::BaseAdapter
+  # code goes here
+end
+
+Blazer.register_adapter "foo", FooAdapter
+```
+
+See the [Presto adapter](https://github.com/ankane/blazer/blob/master/lib/blazer/adapters/presto_adapter.rb) for a good example.
+
+```yml
+data_sources:
+  my_source:
+    adapter: foo
+    url: http://user:password@hostname:9200/
+```
+
 ## Query Permissions
 
 Blazer supports a basic permissions model.