1
0
Fork 0
Runtime calls in crystal
Datei suchen
Arthur POULET f8791dff78
Merge branch 'master' of github.com:Nephos/RuntimeCall
2017-09-12 08:14:34 +02:00
spec Change structure so it bypass the Recursive Generics bug 2017-08-26 01:59:28 +02:00
src Add escape to yield 2017-09-11 21:30:21 +02:00
.editorconfig Init project 2017-08-22 11:59:12 +01:00
.gitignore Init project 2017-08-22 11:59:12 +01:00
.travis.yml Init project 2017-08-22 11:59:12 +01:00
LICENSE Init project 2017-08-22 11:59:12 +01:00
README.md Update README 2017-09-12 08:14:21 +02:00
shard.yml Init project 2017-08-22 11:59:12 +01:00

README.md

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

  1. Fork it ( https://github.com/Nephos/RuntimeCall/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • Nephos Arthur Poulet - creator, maintainer