-
Notifications
You must be signed in to change notification settings - Fork 1
Extending ECell
benzrf edited this page Jul 27, 2016
·
3 revisions
To make your own Stroke, just subclass Line
. initialize
should take one argument (options
), set @socket
to the socket you're going to use, and then call super(self, options)
. In order for the autoloading mechanism to be able to find it by the ID shapename_strokename
, you should set ECell::Autoload::Strokes::Shapename::Strokename
to the stroke. Here's an example of a Stroke that can be loaded as awareness_subscribe
:
module ECell::Autoload::Strokes
module Awareness
class Subscribe < ECell::Elements::Line
def initialize(options={})
@socket = Socket::Sub.new
super(self, options)
@socket.subscribe("")
end
end
end
end
To make your own Shape, just subclass Figure
. Each Face of the Shape should be a module in the Shape. You can use the method Figure.lines
to generate shortcut methods for accessing the Lines that the Figure will use. Here's an example:
class Storage < ECell::Elements::Figure
lines :storage_req, :storage_rep, :storage_push, :storage_pull
def initialize(options)
super
@stored = {}
end
# example is WIP - will write the rest later
module Store
end
module Query
end
end
See the documentation for ECell::Elements::Design
.