百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

flag_shih_tzu

> 编程语言
开源

ActiveRecord 的位域

511 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

ActiveRecord 的位域

FlagShihTzu

⚠️ v1.0.0 => breaking change in default config ⚠️

Want old behavior?

ruby
FlagShihTzu.default_flag_query_mode = :in_list

✨️ The old behavior is not deprecated, is still more performant, and will always be supported.

The new default allows safe-by-default rolling deployments with flag migrations.

Read more here: https://dev.to/galtzo/why-flagshihtzu-is-changing-its-default-sql-for-bit-flags-41l9

[![Version][versioni]][version] [![GitHub tag (latest SemVer)][⛳️tag-img]][⛳️tag] [![License: MIT][license-img]][license] [![Downloads Rank][dl-ranki]][dl-rank] [![CodeCov Test Coverage][codecovi]][codecov] [![Coveralls Test Coverage][coveralls-img]][coveralls] [![QLTY Test Coverage][qlty-covi]][qlty-cov] [![QLTY Maintainability][qlty-mnti]][qlty-mnt] [![CI Heads][3-hd-wfi]][3-hd-wf] [![CI Runtime Dependencies @ HEAD][12-crh-wfi]][12-crh-wf] [![CI Current][11-c-wfi]][11-c-wf] [![CI Truffle Ruby][9-t-wfi]][9-t-wf] [![CI JRuby][10-j-wfi]][10-j-wf] [![Deps Locked][13-️-wfi]][13-️-wf] [![Deps Unlocked][14-️-wfi]][14-️-wf] [![CI Test Coverage][2-cov-wfi]][2-cov-wf] [![CI Style][5-st-wfi]][5-st-wf] [![Apache SkyWalking Eyes License Compatibility Check][15--wfi]][15--wf] [![FOSSA Status][fossa-img]][fossa]

if ci_badges.map(&:color).detect { it != "green"} ☝️ [let me know][️galtzo-floss], as I may have missed the [discord notification][️galtzo-floss].


if ci_badges.map(&:color).all? { it == "green"} ️ send money so I can do more of this. FLOSS maintenance is now my full-time job.

[![OpenCollective Backers][osc-backers-i]][osc-backers] [![OpenCollective Sponsors][osc-sponsors-i]][osc-sponsors] [![Sponsor Me on Github][sponsor-img]][sponsor] [![Liberapay Goal Progress][⛳liberapay-img]][⛳liberapay] [![Donate on PayPal][paypal-img]][paypal] [![Buy me a coffee][buyme-small-img]][buyme] [![Donate at ko-fi.com][kofi-img]][kofi]

How will this project approach the September 2025 hostile takeover of RubyGems? ️

I've summarized my thoughts in this blog post.

Synopsis

An extension for ActiveRecord to store a collection of boolean attributes in a single integer column as a [bit field][bit_field].

This gem lets you use a single integer column in an ActiveRecord model to store a collection of boolean attributes (flags). Each flag can be used almost in the same way you would use any boolean attribute on an ActiveRecord object.

New for v1.0: FlagShihTzu also supports multi-bit fields with value_mode: :tri_state, bit_width:, and custom encoder: implementations. That lets one flag slot represent true, false, and nil, or other enum-like states you encode, while still sharing the same integer column.

The benefits:

  • No schema migrations needed for new boolean attributes. This helps a lot if you have very large db-tables, on which you want to avoid ALTER TABLE whenever possible. Data migrations that set newly added flags still need deploy-safe query behavior, described below.
  • Only the one integer column needs to be indexed.
  • [Bitwise Operations][bitwise_operation] are fast!

Using FlagShihTzu, you can add new boolean attributes whenever you want, without needing any migration. Just add a new flag to the has_flags call.

What is a "Shih Tzu"?

Info you can shake a stick at

Tokens to Remember [![Gem name][⛳️name-img]][⛳️gem-name] [![Gem namespace][⛳️namespace-img]][⛳️gem-namespace]
Works with JRuby [![JRuby 9.2 Compat][jruby-9.2i]][jruby-9.2-wf] [![JRuby 9.3 Compat][jruby-9.3i]][jruby-9.3-wf]
[![JRuby 9.4 Compat][jruby-9.4i]][jruby-9.4-wf] [![JRuby 10.0 Compat][jruby-10.0i]][jruby-10.0-wf] [![JRuby current Compat][jruby-c-i]][10-j-wf] [![JRuby HEAD Compat][jruby-headi]][3-hd-wf]
Works with Truffle Ruby [![Truffle Ruby 22.3 Compat][truby-22.3i]][truby-22.3-wf] [![Truffle Ruby 23.0 Compat][truby-23.0i]][truby-23.0-wf] [![Truffle Ruby 23.1 Compat][truby-23.1i]][truby-23.1-wf]
[![Truffle Ruby 24.2 Compat][truby-24.2i]][truby-24.2-wf] [![Truffle Ruby 25.0 Compat][truby-25.0i]][truby-25.0-wf] [![Truffle Ruby 33.0 Compat][truby-33.0i]][truby-33.0-wf] [![Truffle Ruby current Compat][truby-c-i]][9-t-wf] [![Truffle Ruby HEAD Compat][truby-headi]][3-hd-wf]
Works with MRI Ruby 4 [![Ruby current Compat][ruby-c-i]][11-c-wf] [![Ruby HEAD Compat][ruby-headi]][3-hd-wf]
Works with MRI Ruby 3 [![Ruby 3.0 Compat][ruby-3.0i]][ruby-3.0-wf] [![Ruby 3.1 Compat][ruby-3.1i]][ruby-3.1-wf] [![Ruby 3.2 Compat][ruby-3.2i]][ruby-3.2-wf] [![Ruby 3.3 Compat][ruby-3.3i]][ruby-3.3-wf] [![Ruby 3.4 Compat][ruby-3.4i]][ruby-3.4-wf]
Works with MRI Ruby 2 [![Ruby 2.4 Compat][ruby-2.4i]][ruby-2.4-wf] [![Ruby 2.5 Compat][ruby-2.5i]][ruby-2.5-wf] [![Ruby 2.6 Compat][ruby-2.6i]][ruby-2.6-wf] [![Ruby 2.7 Compat][ruby-2.7i]][ruby-2.7-wf]
Support & Community [![Join Me on Daily.dev's RubyFriends][✉️ruby-friends-img]][✉️ruby-friends] [![Get help from RubyForum][✉️ruby-forum-img]][✉️ruby-forum] [![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite] [![Get help from me on Upwork][‍expsup-upwork-img]][‍expsup-upwork] [![Get help from me on Codementor][‍expsup-codementor-img]][‍expsup-codementor]
Source [![Source on GitLab.com][src-gl-img]][src-gl] [![Source on CodeBerg.org][src-cb-img]][src-cb] [![Source on GitHub.com][src-gh-img]][src-gh] [![The best SHA: dQw4w9WgXcQ!][kloc-img]][kloc]
Documentation [![Current release on RubyDoc.info][docs-cr-rd-img]][yard-current] [![YARD on Galtzo.com][docs-head-rd-img]][yard-head] [![Maintainer Blog][maint-blog-img]][maint-blog] [![GitLab Wiki][gl-wiki-img]][gl-wiki] [![GitHub Wiki][gh-wiki-img]][gh-wiki]
Compliance [![License: MIT][license-img]][license] [![Apache license compatibility: Category A][license-compat-img]][license-compat] [![ilo-declaration-img]][ilo-declaration] [![Security Policy][security-img]][security] [![Contributor Covenant 2.1][conduct-img]][conduct] [![SemVer 2.0.0][semver-img]][semver]
Style [![Enforced Code Style Linter][rlts-img]][rlts] [![Keep-A-Changelog 1.0.0][keep-changelog-img]][keep-changelog] [![Gitmoji Commits][gitmoji-img]][gitmoji] [![Compatibility appraised by: appraisal2][appraisal2-img]][appraisal2]
Maintainer ️ [![Follow Me on LinkedIn][linkedin-img]][linkedin] [![Follow Me on Ruby.Social][ruby-mast-img]][ruby-mast] [![Follow Me on Bluesky][bluesky-img]][bluesky] [![Contact Maintainer][maint-contact-img]][maint-contact] [![My technical writing][‍♂️devto-img]][‍♂️devto]
... [![Find Me on WellFound:][✌️wellfound-img]][✌️wellfound] [![Find Me on CrunchBase][crunchbase-img]][crunchbase] [![My LinkTree][linktree-img]][linktree] [![More About Me][‍♂️aboutme-img]][‍♂️aboutme] [][berg] [][hub] [][hut] [][lab]

Compatibility

Compatible with MRI Ruby 2.4+, JRuby, and TruffleRuby. CI workflows and Appraisals are generated for MRI Ruby 2.4+. This test floor is configured by ruby.test_minimum in .kettle-jem.yml and may be higher than the gem's runtime compatibility floor when legacy Rubies are not practical for the current toolchain.

The amazing test matrix is powered by the kettle-dev stack.

How kettle-dev manages complexity in tests

Gem Source Role Total downloads
appraisal2 GitHub multi-dependency Appraisal matrix generation
appraisal2-rubocop GitHub RuboCop Appraisal generator integration
kettle-dev GitHub development, release, and CI workflow tooling
kettle-jem GitHub Appraisals & CI workflow templates
kettle-soup-cover GitHub SimpleCov coverage policy and reporting
kettle-test GitHub standard test runner and coverage harness
rubocop-lts GitHub Ruby-version-aware linting
turbo_tests2 GitHub parallel test execution

Federated DVCS

Find this repo on federated forges (Coming soon!)

Federated [DVCS][d-in-dvcs] Repository Status Issues PRs Wiki CI
[galtzo-floss/flag_shih_tzu on GitLab][src-gl] The Truth [][gl-issues] [][gl-pulls] [][gl-wiki] Tiny Matrix
[galtzo-floss/flag_shih_tzu on CodeBerg][src-cb] An Ethical Mirror ([Donate][cb-donate]) [][cb-issues] [][cb-pulls] ➖ ⭕️ No Matrix
[galtzo-floss/flag_shih_tzu on GitHub][src-gh] Another Mirror [][gh-issues] [][gh-pulls] [][gh-wiki] Full Matrix

Enterprise Support

Available as part of the Tidelift Subscription.

Need enterprise-level guarantees?

The maintainers of this and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use.

[![Get help from me on Tidelift][️entsup-tidelift-img]][️entsup-tidelift]

  • Subscribe for support guarantees covering all your FLOSS dependencies
  • Tidelift is part of [Sonar][️entsup-tidelift-sonar]
  • Tidelift pays maintainers to maintain the software you depend on! @Pointy Haired Boss: An [enterprise support][️entsup-tidelift] subscription is "[never gonna let you down][kloc]", and supports open source maintainers

Alternatively:

  • [![Ruby Users Forum][✉️ruby-forum-img]][✉️ruby-forum]
  • [![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite]
  • [![Get help from me on Upwork][‍expsup-upwork-img]][‍expsup-upwork]
  • [![Get help from me on Codementor][‍expsup-codemen

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubyactiverecordbitfieldrubyrubygem

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言