behaves:定义代码之间的行为和契约

时间:2021-03-15 09:09:04
【文件属性】:
文件名称:behaves:定义代码之间的行为和契约
文件大小:13KB
文件格式:ZIP
更新时间:2021-03-15 09:09:04
ruby gem Ruby 行为 行为是一个宝石,可以帮助您定义类之间的行为。 在定义行为时告别运行时错误。 行为通过确保所有适配器都定义了必需的行为,对于处理适配器模式特别有用。 有关更多示例,请参见的。 以下各节中有详细说明。 安装 将此行添加到应用程序的Gemfile中: gem 'behaves' 用法 这就是定义行为与behaves 。 首先,使用implements方法在Behavior Object上定义所需的方法,该方法带有方法列表。 class Animal extend Behaves implements :speak , :eat end 然后,您可以使用behaves_like方法将任何对象( Behaving Object )转换为类似于Behavior Object的Behavior Object ,该方法采用Behavior Object 。 class Dog
【文件预览】:
behaves-master
----.gitignore(119B)
----.rspec(53B)
----bin()
--------setup(131B)
--------console(342B)
----CODE_OF_CONDUCT.md(3KB)
----LICENSE.txt(1KB)
----behaves.gemspec(1KB)
----spec()
--------behaves_spec.rb(8KB)
--------spec_helper.rb(425B)
----README.md(6KB)
----lib()
--------behaves()
--------behaves.rb(2KB)
----.circleci()
--------config.yml(2KB)
----Gemfile(162B)
----Rakefile(117B)
----Gemfile.lock(845B)

网友评论