All Projects → jasl-lab → duck_record

jasl-lab / duck_record

Licence: other
Used for creating virtual models like ActiveType or ModelAttribute does.

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to duck record

active model serializers validator
🃏 An extension to ActiveModel::Serializer that validates serializers output against a JSON schema
Stars: ✭ 18 (-21.74%)
Mutual labels:  activerecord, activemodel
u-observers
Simple and powerful implementation of the observer pattern.
Stars: ✭ 31 (+34.78%)
Mutual labels:  activerecord, activemodel
activeentity
Active Record without Database
Stars: ✭ 46 (+100%)
Mutual labels:  activerecord, activemodel
Elasticsearch Rails
Elasticsearch integrations for ActiveModel/Record and Ruby on Rails
Stars: ✭ 2,896 (+12491.3%)
Mutual labels:  activerecord, activemodel
active snapshot
Simplified snapshots and restoration for ActiveRecord models and associations with a transparent white-box implementation
Stars: ✭ 67 (+191.3%)
Mutual labels:  activerecord
query-objects-example
Example of rails app using Query Objects
Stars: ✭ 37 (+60.87%)
Mutual labels:  activerecord
acfs
API client for services
Stars: ✭ 13 (-43.48%)
Mutual labels:  activemodel
Occams Record
The missing high-efficiency query API for ActiveRecord
Stars: ✭ 240 (+943.48%)
Mutual labels:  activerecord
sinatra-dev-cheatsheet
A quick-and-dirty cheat sheet for creating HTML/CSS websites, and developing using Sinatra and ActiveRecord.
Stars: ✭ 44 (+91.3%)
Mutual labels:  activerecord
departure
Percona's pt-online-schema-change runner for ActiveRecord migrations.
Stars: ✭ 86 (+273.91%)
Mutual labels:  activerecord
attribute-depends-calculator
Automatically calculate a collection of depends attribute of ActiveRecord
Stars: ✭ 41 (+78.26%)
Mutual labels:  activerecord
activerecord-migrations
A gem to simplify activerecord migrations in non-rails projects.
Stars: ✭ 15 (-34.78%)
Mutual labels:  activerecord
blade-jdbc
🐜 move to https://github.com/biezhi/anima
Stars: ✭ 36 (+56.52%)
Mutual labels:  activerecord
n1 loader
Loader to solve N+1 issues for good. Highly recommended for GraphQL API.
Stars: ✭ 182 (+691.3%)
Mutual labels:  activerecord
activerecord-crate-adapter
Ruby on Rails ActiveRecord adapter for CrateDB
Stars: ✭ 27 (+17.39%)
Mutual labels:  activerecord
Scenic
Scenic is maintained by Derek Prior, Caleb Hearth, and you, our contributors.
Stars: ✭ 2,856 (+12317.39%)
Mutual labels:  activerecord
activerecord-debug errors
An extension of activerecord to display useful debug logs on errors
Stars: ✭ 23 (+0%)
Mutual labels:  activerecord
active dynamic
Gem that allows to add attributes to your active models dynamically
Stars: ✭ 61 (+165.22%)
Mutual labels:  activerecord
yii2-activerecord-inheritance
ActiveRecord Inheritance is an util to provide the Class Table Inheritance Pattern the to the Yii2 framework
Stars: ✭ 18 (-21.74%)
Mutual labels:  activerecord
embedded
Rails/Activerecord plugin to make value objects embedded into active record objects
Stars: ✭ 48 (+108.7%)
Mutual labels:  activerecord

Duck Record

It looks like Active Record and quacks like Active Record, it's Duck Record! Actually it's extract from Active Record.

Usage

class Person < DuckRecord::Base
  attribute :name, :string
  attribute :age, :integer

  validates :name, presence: true
end

class Comment < DuckRecord::Base
  attribute :content, :string

  validates :content, presence: true
end

class Book < DuckRecord::Base
  embeds_one :author, class_name: 'Person', validate: true
  accepts_nested_attributes_for :author

  embeds_many :comments, validate: true
  accepts_nested_attributes_for :comments

  attribute :title,     :string
  attribute :tags,      :string,   array:   true
  attribute :price,     :decimal,  default: 0
  attribute :meta,      :json,     default: {}
  attribute :bought_at, :datetime, default: -> { Time.new } 

  validates :title, presence: true
end

then use these models like a Active Record model, but remember that can't be persisting!

Installation

Since Duck Record is under early development, I suggest you fetch the gem through GitHub.

Add this line to your application's Gemfile:

gem 'duck_record', github: 'jasl/duck_record'

And then execute:

$ bundle

Or install it yourself as:

$ gem install duck_record

TODO

  • refactor that original design for database
  • update docs
  • add useful methods
  • add tests
  • let me know..

Contributing

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with Rakefile or version (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].