【文件属性】:
文件名称:delegates:代表
文件大小:8KB
文件格式:ZIP
更新时间:2021-04-25 19:58:29
ruby delegate Ruby
代表们
这个gem只是从ActiveSupport中将方便的delegate :method1, :method2, method3, to: :receiver的一部分。 它似乎远远优于stdlib的 ,有时在ActiveSupport和Monkey-patching不理想的情况下,我希望使用它。
用法:
gem install delegates
(或将Gemfile gem 'delegates'添加到您的Gemfile )。
然后:
class Employee < Struct . new ( :name , :department , :address )
# ...
extend Delegates
delegate :city , :street , to : :address
# ...
end
employee = Employee . new
【文件预览】:
delegates-master
----.github()
--------workflows()
----delegates.gemspec(1KB)
----lib()
--------delegates.rb(5KB)
----Gemfile(39B)
----spec()
--------delegates_spec.rb(3KB)
--------.rubocop.yml(193B)
----Rakefile(249B)
----README.md(2KB)
----.rubocop.yml(1019B)
----.yardopts(31B)
----.gitignore(29B)