flagpole:使用位图将多个标志存储在Integer字段中

时间:2021-05-26 21:39:43
【文件属性】:
文件名称:flagpole:使用位图将多个标志存储在Integer字段中
文件大小:6KB
文件格式:ZIP
更新时间:2021-05-26 21:39:43
ruby bitfield lesscode flags Ruby 旗杆:用于存储标志的简单位图 旗杆通过将每个标志存储为一个位,允许将一堆标志捆绑到单个整数字段中。 notifications_via = Flagpole . new ( [ :email , :sms , :phone_push ] ) notifications_via . to_h #=> { email: false, sms: false, phone_push: false } notifications_via [ :email ] = true notifications_via [ :sms ] = true notifications_via . to_h #=> { email: true, sms: true, phone_push: false } notifications_via . to_i #=> 3 现在,您只需将这3存储在数据库中即可。 为了
【文件预览】:
flagpole-master
----test()
--------helper.rb(19B)
--------flagpole_test.rb(2KB)
----LICENSE(1KB)
----.gems(16B)
----.gitignore(11B)
----lib()
--------flagpole.rb(2KB)
--------flagpole()
----Makefile(762B)
----flagpole.gemspec(611B)
----README.md(3KB)

网友评论