GithubHelp home page GithubHelp logo

isabella232 / serialized_attributes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from github/serialized_attributes

0.0 0.0 0.0 83 KB

UNMAINTAINED - kind of a bridge between using AR and a full blown schema-free db

License: MIT License

Ruby 100.00%

serialized_attributes's Introduction

UNMAINTAINED

This repo is no longer being maintained as of 2015-08-25.


SerializedAttributes

SerializedAttributes allows you to add an encoded hash to an ActiveRecord model.
This is similar to the built-in ActiveRecord serialization, except that the field is converted to JSON, gzipped, and stored in a BLOB field. This uses the json gem which is much faster than YAML serialization. However, JSON is not nearly as flexible, so you're stuck with strings/integers/dates/etc.

Where possible, ActiveRecord compatible methods are generated so that a migration should be pretty simple. See unit tests for examples.

Some of the code and most of the ideas are taken from Heresy, a ruby implementation of how FriendFeed uses MySQL for schema-free storage.

Supports ActiveRecord 2.2 in ruby 1.8.7, and ActiveRecord 2.3-3.1 in ruby 1.9.3. See Travis CI to see if we support your version of ActiveRecord and ruby.

Setup

Install the plugin into your Rails app.

Usage

class Profile < ActiveRecord::Base
  # assumes #data serializes to raw_data blob field
  serialize_attributes do
    string  :title, :description
    integer :age
    float   :rank, :percentage
    time    :birthday
  end

  # Serializes #data to assumed raw_data blob field
  serialize_attributes :data do
    string  :title, :description
    integer :age
    float   :rank, :percentage
    time    :birthday
  end

  # set the blob field
  serialize_attributes :data, :blob => :serialized_field do
    string  :title, :description
    integer :age
    float   :rank, :percentage
    time    :birthday
  end
end

serialized_attributes's People

Contributors

technoweenie avatar mguterl avatar haileys avatar rtomayko avatar eileencodes avatar tmm1 avatar

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.