Description
A flexible gem for cloning your models. Clowne focuses on ease of use and provides the ability to connect various ORM adapters.
Clowne alternatives and similar gems
Based on the "Abstraction" category.
Alternatively, view Clowne alternatives based on common mentions on social networks and blogs.
-
Interactor
Interactor provides a common interface for performing complex user interactions. -
wisper
A micro library providing Ruby objects with Publish-Subscribe capabilities -
ActiveInteraction
:briefcase: Manage application specific business logic. -
Decent Exposure
A helper for creating declarative interfaces in controllers -
Rails Event Store
A Ruby implementation of an Event Store based on Active Record -
Mutations
Compose your business logic into commands that sanitize and validate input. -
dry-types
Flexible type system for Ruby with coercions and constraints -
Amoeba
A ruby gem to allow the copying of ActiveRecord objects and their associated children, configurable with a DSL on the model -
Inline SVG
Embed SVG documents in your Rails views and style them with CSS -
SimpleCommand
A simple, standardized way to build and use Service Objects (aka Commands) in Ruby -
Waterfall
A slice of functional programming to chain ruby services and blocks, thus providing a new approach to flow control. Make them flow! -
u-service
Represent use cases in a simple and powerful way while writing modular, expressive and sequentially logical code. -
Surrounded
Create encapsulated systems of objects and focus on their interactions -
PageletRails
Improve perceived performance of your rails application with minimum effort -
Smart Init - Simple service objects in Ruby
A simple gem for eliminating Ruby initializers boilerplate code, and providing unified service objects API -
SuperModule
SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base). This also succeeds ActiveSupport::Concern by offering lighter syntax -
skinny_controllers
A pattern for allowing for easier testing of large projects' business logic -
Invokable
Objects are functions! Treat any Object or Class as a Proc (like Enumerable but for Procs). -
EasilyTypable
Ruby module that facilitates English-like type checking in an inheritance hierarchy via "type_name?" methods -
grpc_serializer
A simple library to encode nested hash to grpc object and vice versa -
simple_active_link_to
Simple rails view helper to manage "active" state of a link -
dry-rb
dry-rb is a collection of next-generation Ruby libraries, each intended to encapsulate a common task.
Access the most powerful time series database as a service
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Clowne or a related project?
README
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.
๐ Documentation
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 all licence references and agreements mentioned in the Clowne README section above
are relevant to that project's source code only.