Project

findable

0.0
No commit activity in last 3 years
No release in over 3 years
Redis wrapper with API like ActiveRecord.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Findable

Gem Version Build Status Coverage Status Code Climate

Redis wrapper with API like ActiveRecord.

Requirements

  • Redis 2.8 or later

Installation

Add this line to your application's Gemfile:

gem "findable"

And then execute:

$ bundle

Setup config file and seed script:

$ rails generate findable:install

Added following files:

  • config/initializers/findable.rb
    • Config file for Findable.
  • db/findable_seeds.rb
    • Seed script for Findable.
  • db/findable_seeds/.keep
    • Directory for storing seed files of Findable.

Usage

Create seed file if static data.

Example db/findable_seeds/tags.yml:

data1:
  id: 1
  name: Ruby

Create model.

Example app/models/tag.rb:

class Tag < Findable::Base
end

Execute seed script if you create seed files.

$ rake findable:seed

Manipulate data with API like ActiveRecord.

$ rails console
pry(main)> Tag.find(1)
=> #<Tag id: 1, name: "Ruby">
pry(main)> golang = Tag.create(name: "Go")
=> #<Tag id: 2, name: "Go">
pry(main)> Tag.all.each {|tag| p tag.name }
"Ruby"
"Go"
=> [#<Tag id: 1, name: "Ruby">, #<Tag id: 2, name: "Go">]

Associations

It is possible to use the belongs_to and has_one and has_many. Mutually can refer to objects of ActiveRecord and Findable.

class Article < ActiveRecord::Base
  include Findable::Associations::ActiveRecordExt
  belongs_to :tag
end

class Tag < Findable::Base
  has_many :articles
end

Contributing

  1. Fork it ( https://github.com/i2bskn/findable/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request