blueprinter:用于Ruby的简单,快速和声明性序列化库

时间:2021-02-02 04:23:42
【文件属性】:
文件名称:blueprinter:用于Ruby的简单,快速和声明性序列化库
文件大小:50KB
文件格式:ZIP
更新时间:2021-02-02 04:23:42
ruby rails json serializer resource-serializer 蓝图 Blueprinter是用于Ruby的JSON对象呈现器,用于获取业务对象并将其分解为简单的哈希并将它们序列化为JSON。 可以在Rails中代替其他序列化器(如JBuilder或ActiveModelSerializers)使用。 它被设计为简单,直接和高效的。 它严重依赖于views的概念,类似于Rails视图,它们是在不同上下文中预定义数据输出的方式。 文献资料 可以在找到文档。 用法 基本的 如果您有想要序列化的对象,只需创建一个蓝图。 举例来说,您有一个具有以下属性的用户记录[:uuid, :email, :first_name, :last_name, :password, :address] 。 您可以这样定义一个简单的蓝图: class UserBlueprint < Blueprinter :: Base identifier :uuid fields :first_name , :last_name , :email end 然后,在您的代码中: puts UserBlueprint . render ( user ) # Output is
【文件预览】:
blueprinter-master
----.gitignore(167B)
----.rspec(45B)
----bin()
--------test(138B)
----blueprinter.gemspec(2KB)
----CHANGELOG.md(12KB)
----blueprinter_logo.svg(4KB)
----spec()
--------units()
--------integrations()
--------factories()
--------generators()
--------activerecord_helper.rb(1KB)
--------spec_helper.rb(546B)
--------benchmarks()
--------generator_helper.rb(866B)
--------benchmark_helper.rb(221B)
----README.md(22KB)
----lib()
--------generators()
--------blueprinter()
--------blueprinter.rb(60B)
--------tasks()
----.circleci()
--------config.yml(2KB)
----Gemfile(566B)
----MIT-LICENSE(1KB)
----Rakefile(697B)

网友评论