Runtime calls in crystal
spec | ||
src | ||
.editorconfig | ||
.gitignore | ||
.travis.yml | ||
LICENSE | ||
README.md | ||
shard.yml |
RuntimeCall
Runtime calls in crystal
Looks like "send" in Ruby.
It is an internal list of functions defined to be called by their
stringified name ("bar"
call the function bar(...)
).
Installation
Add this to your application's shard.yml
:
dependencies:
RuntimeCall:
github: Nephos/RuntimeCall
Usage
require "RuntimeCall"
class Foooo
end
class Foo
@a : Int32
def initialize(@a)
end
RuntimeCall.extends do
getter_runtime_call "a"
define_runtime_call "bar", Int32 do |args|
@a += args[0]
end
define_runtime_call "bar2" do |args|
Foooo.new
end
end
end
foo = Foo.new a: 1
foo.runtime_call "bar", 2
foo.runtime_call "a" # => 3
foo.runtime_call "bar2" # => #<Foo:...>
Development
TODO: Write development instructions here
Contributing
- Fork it ( https://github.com/Nephos/RuntimeCall/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- Nephos Arthur Poulet - creator, maintainer