RuntimeCall

Runtime calls in crystal

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
Repository

RuntimeCall

Owner
Statistic
  • 0
  • 1
  • 0
  • 1
  • 0
  • about 7 years ago
  • August 22, 2017
License

MIT License

Links
Synced at

Fri, 22 Nov 2024 06:41:10 GMT

Languages