Setsy alternatives and similar gems
Based on the "Abstraction" category.
Alternatively, view Setsy alternatives based on common mentions on social networks and blogs.
-
Amoeba
A ruby gem to allow the copying of ActiveRecord objects and their associated children, configurable with a DSL on the model -
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. -
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 -
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 -
dry-rb
dry-rb is a collection of next-generation Ruby libraries, each intended to encapsulate a common task.
Scout Monitoring - Performance metrics and, now, Logs Management Monitoring with Scout Monitoring
* 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 Setsy or a related project?
README
Setsy
Settings for your classes. Depends on ActiveModel 3.0+.
Obligatory blog post
Here.
Note
This is not very tidy as it is. But it's battle-tested.
You want this if...
You want this if you don't want to have a zillion columns per model to manage your settings.
Installation
Add this line to your application's Gemfile:
gem 'setsy'
And then execute:
$ bundle
Or install it yourself as:
$ gem install setsy
Usage
First, create a migration for a JSONB column. Call it settings_data
, or something. Just don't call it settings
if you want to be able to call settings
on an instance. Default of {}
In app/models/user.rb
:
class User < ApplicationRecord
include ::Setsy::DSL
# each setting can be a hash, like posts_limit, or just
DEFAULT_SETTINGS = {
posts_limit: { value: 10 },
favorite_color: 'blue'
}.freeze
# do some stuff.
# setsy <attribute_name>, <options>, <block of readers>
setsy :settings, column: :settings_data, defaults: DEFAULT_SETTINGS do |conf|
conf.reader :posts_limit_and_color do
"posts limit is #{posts_limit} and color is #{favorite_color}"
end
end
end
These attributes will become available on User#settings
, and will be backed by the settings_data
column which you created as a JSONB column.
Then in your controller or view or something,
<% @user = User.first %>
<% if @user.settings.posts_limit.default? %>
Posts limit is default.
<% else %>
Posts limit is <%= @user.settings.posts_limit %>
<% end %>
<%= @user.settings.posts_limit_and_color %>
Testing
See spec
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/joshmn/setsy.