README.md in looksist-0.0.8 vs README.md in looksist-0.1.0
- old
+ new
@@ -26,12 +26,14 @@
### With Object Models (Her, Active Resource or any of your choice)
* Add an initializer to configure looksist
``` ruby
-Looksist.lookup_store_client ||= Redis.new(:url => (ENV['REDIS_URL'], :driver => :hiredis)
-Looksist.driver = Looksist::Serializers::Her
+Looksist.configure do |looksist|
+ looksist.lookup_store = Redis.new(:url => (ENV['REDIS_URL'], :driver => :hiredis)
+ looksist.driver = Looksist::Serializers::Her
+end
```
You need to specify the driver to manage the attributes. In this case, we use [HER](https://github.com/remiprev/her). You can add support for ActiveResource or ActiveRecord as needed (also refer to specs for free form usage without a driver).
* Please find the sample rspec to understand the usage and internals
@@ -47,11 +49,11 @@
@id = id
end
end
end
- expect(Looksist.lookup_store_client).to receive(:get).with('ids/1').and_return('Employee Name')
+ expect(Looksist.lookup_store).to receive(:get).with('ids/1').and_return('Employee Name')
e = SimpleLookup::Employee.new(1)
expect(e.name).to eq('Employee Name')
end
```
lookup takes the following form:
@@ -69,29 +71,19 @@
```
### With Plain Hashes
-* Add an initializer to configure looksist
-```ruby
-redis_client ||= Redis.new(:url => (ENV['REDIS_URL'], :driver => :hiredis)
-
-Looksist::Hashed.redis_service = Looksist::RedisService.instance do |lookup|
- lookup.client = redis_client
-end
-
-```
-
#### Columnar Hashes
* First Level look ups
```ruby
it 'should inject multiple attribute to an existing hash' do
class HashService
- include Looksist::Hashed
+ include Looksist
def metrics
{
table: {
employee_id: [5, 6],
@@ -119,11 +111,11 @@
* Inner Lookups using [JsonPath](https://github.com/joshbuddy/jsonpath)
```ruby
it 'should inject multiple attribute to an existing deep hash' do
class EmployeeHash
- include Looksist::Hashed
+ include Looksist
def metrics
{
table: {
database: {
@@ -154,10 +146,10 @@
#### Non Columnar Hashes
```ruby
it 'should be capable to deep lookup and inject' do
class Menu
- include Looksist::Hashed
+ include Looksist
def metrics
{
table: {
menu: [