replicator v0.1.0
Replicator
Replicator is a class registry and factory.
Installation
-
Add the dependency to your
shard.yml:dependencies: replicator: github: first-try-software/replicator -
Run
shards install
Usage
require "replicator"
abstract class Starship
extend Replicator::Replicable
end
class Enterprise < Starship
replicates :galaxy
end
class Cerritos < Starship
replicates :galaxy
end
Starship.replicate(:galaxy) # => [#<Enterprise:0x1099ddd60>, #<Cerritos:0x1099ddd70>] : Array(Starship)
Roadmap
Replicator is ready to use in it's current state. The interfaces are unlikey to change. But, there will be new features added per our roadmap:
- Abstract classes can extend Replicator::Replicable to make their descendants "replicable"
- Concrete, "replicable" classes can self register under one or more keys by calling
replicates :symbol - Multiple concrete, "replicable" classes can self register under the same key by calling
replicates :symbol - Registered, "replicable" classes can be instantiated using the abstract parent's
.replicate(:symbol)method - Positional and named arguments may be passed when initializing "replicable" classes
- A "replicable" class may register as the
default_replicafor an extended abstract parent class, and will be instantiated when an unknown key is requested (good for the null object pattern) - A "replicable" class may register as
replicates_allin which case, it is always instantiated and returned in addition to the classes that match a requested key
Contributing
- Fork it (https://github.com/first-try-software/replicator/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
- Alan Ridlehoover - co-creator and maintainer
- Fito von Zastrow - co-creator and maintainer
Repository
replicator
Owner
Statistic
- 2
- 0
- 0
- 0
- 1
- almost 3 years ago
- January 4, 2023
License
MIT License
Links
Synced at
Sun, 14 Dec 2025 11:55:04 GMT
Languages