clowne-rb / Clowne
Licence: mit
A flexible gem for cloning models
Stars: ✭ 260
Programming Languages
ruby
36898 projects - #4 most used programming language
Labels
Projects that are alternatives of or similar to Clowne
Calculate All
calculate_all method for aggregate functions in Active Record
Stars: ✭ 118 (-54.62%)
Mutual labels: activerecord, rails
Graphql Query Resolver
Minimize N+1 queries generated by GraphQL and ActiveRecord
Stars: ✭ 148 (-43.08%)
Mutual labels: activerecord, rails
Closure tree
Easily and efficiently make your ActiveRecord models support hierarchies
Stars: ✭ 1,665 (+540.38%)
Mutual labels: activerecord, rails
Active record Events
Manage timestamps in ActiveRecord models
Stars: ✭ 109 (-58.08%)
Mutual labels: activerecord, rails
Secondbase
Seamless second database integration for Rails.
Stars: ✭ 216 (-16.92%)
Mutual labels: activerecord, rails
Active hash relation
ActiveHash Relation: Simple gem that allows you to run multiple ActiveRecord::Relation using hash. Perfect for APIs.
Stars: ✭ 115 (-55.77%)
Mutual labels: activerecord, rails
Torque Postgresql
Add support to complex resources of PostgreSQL, like data types, array associations, and auxiliary statements (CTE)
Stars: ✭ 130 (-50%)
Mutual labels: activerecord, rails
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (-61.54%)
Mutual labels: activerecord, rails
Activerecord Turntable
ActiveRecord Sharding Plugin
Stars: ✭ 206 (-20.77%)
Mutual labels: activerecord, rails
Jsonapi Utils
Build JSON API-compliant APIs on Rails with no (or less) learning curve.
Stars: ✭ 191 (-26.54%)
Mutual labels: activerecord, rails
Activerecord Postgres enum
Integrate PostgreSQL's enum data type into ActiveRecord's schema and migrations.
Stars: ✭ 227 (-12.69%)
Mutual labels: activerecord, rails
Counter culture
Turbo-charged counter caches for your Rails app.
Stars: ✭ 1,397 (+437.31%)
Mutual labels: activerecord, rails
Where Or
Where or function backport from Rails 5 for Rails 4.2
Stars: ✭ 116 (-55.38%)
Mutual labels: activerecord, rails
Activerecord Clean Db Structure
Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
Stars: ✭ 101 (-61.15%)
Mutual labels: activerecord, rails
Activerecord where assoc
Make ActiveRecord do conditions on your associations
Stars: ✭ 126 (-51.54%)
Mutual labels: activerecord, rails
Validates timeliness
Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
Stars: ✭ 1,319 (+407.31%)
Mutual labels: activerecord, rails
Active record replica
Redirect ActiveRecord (Rails) reads to replica databases while ensuring all writes go to the primary database.
Stars: ✭ 96 (-63.08%)
Mutual labels: activerecord, rails
Ooor
Odoo Ruby JSON client. Emulates ActiveRecord enough (as much as Mongoid; Implements ActiveModel) to make Rails development with an Odoo datastore straightforward
Stars: ✭ 184 (-29.23%)
Mutual labels: activerecord, rails
Seamless database pool
Add support for master/slave database clusters in ActiveRecord to improve performance.
Stars: ✭ 222 (-14.62%)
Mutual labels: activerecord, rails
Clowne
A flexible gem for cloning your models. Clowne focuses on ease of use and provides the ability to connect various ORM adapters.
📖 Read Evil Martians Chronicles to learn about possible use cases.
Installation
To install Clowne with RubyGems:
gem install clowne
Or add this line to your application's Gemfile:
gem "clowne"
Quick Start
Assume that you have the following model:
class User < ActiveRecord::Base
# create_table :users do |t|
# t.string :login
# t.string :email
# t.timestamps null: false
# end
has_one :profile
has_many :posts
end
class Profile < ActiveRecord::Base
# create_table :profiles do |t|
# t.string :name
# end
end
class Post < ActiveRecord::Base
# create_table :posts
end
Let's declare our cloners first:
class UserCloner < Clowne::Cloner
adapter :active_record
include_association :profile, clone_with: SpecialProfileCloner
include_association :posts
nullify :login
# params here is an arbitrary Hash passed into cloner
finalize do |_source, record, **params|
record.email = params[:email]
end
end
class SpecialProfileCloner < Clowne::Cloner
adapter :active_record
nullify :name
end
Now you can use UserCloner
to clone existing records:
user = User.last
# => <#User id: 1, login: 'clown', email: '[email protected]'>
operation = UserCloner.call(user, email: "[email protected]")
# => <#Clowne::Utils::Operation...>
operation.to_record
# => <#User id: nil, login: nil, email: '[email protected]'>
operation.persist!
# => true
cloned = operation.to_record
# => <#User id: 2, login: nil, email: '[email protected]'>
cloned.login
# => nil
cloned.email
# => "[email protected]"
# associations:
cloned.posts.count == user.posts.count
# => true
cloned.profile.name
# => nil
Take a look at our documentation for more info!
Supported ORM adapters
Adapter | 1:1 | *:1 | 1:M | M:M |
---|---|---|---|---|
Active Record | has_one | belongs_to | has_many | has_and_belongs_to |
Sequel | one_to_one | - | one_to_many | many_to_many |
Maintainers
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].