【文件属性】:
文件名称:invokr:使用一致的 Hash 接口调用方法
文件大小:16KB
文件格式:ZIP
更新时间:2021-06-27 20:36:36
Ruby
调用者
使用一致的 Hash 接口调用方法。 对元编程很有用。
基本用法
假设您有一个要调用的方法:
class BankAccount
def add_transaction ( amount , account_id : , description : '' )
# adds transaction
end
end
您可以通过纯 ruby 的类接口调用此方法。 但有时你有一个包含参数的哈希。 这就是 Invokr 的用武之地:
bank_account = BankAccount . new
params = JSON . parse http_request . response_body
Invokr . invoke method : :add_transaction , on : bank_account , with : params
在幕后,
【文件预览】:
invokr-master
----bin()
--------test_runner(321B)
--------rake(414B)
----invokr.gemspec(956B)
----Rakefile(536B)
----test()
--------query_test.rb(2KB)
--------dependency_injection_test.rb(1KB)
--------test_helper.rb(1KB)
--------optional_args_test.rb(2KB)
--------block_args_test.rb(2KB)
--------rest_args_test.rb(440B)
--------invokr_test.rb(635B)
--------required_args_test.rb(1KB)
--------keyword_args_test.rb(2KB)
----Gemfile(91B)
----.gitignore(204B)
----lib()
--------invokr.rb(2KB)
--------invokr()
----README.md(4KB)
----LICENSE.txt(1KB)