Module: Evolvable::GeneCluster::ClassMethods
- Defined in:
- lib/evolvable/gene_cluster.rb
Overview
Class methods added to classes that include Evolvable::GeneCluster
Instance Method Summary collapse
-
#apply_cluster(evolvable_class, cluster_name, **_) ⇒ void
Applies all genes in this cluster to the given evolvable class.
-
#gene(name, **opts) ⇒ Object
Defines a gene in the cluster.
-
#inherited(subclass) ⇒ void
Ensures that subclasses inherit the cluster configuration.
Instance Method Details
#apply_cluster(evolvable_class, cluster_name, **_) ⇒ void
This method returns an undefined value.
Applies all genes in this cluster to the given evolvable class.
This is called automatically when using the cluster
macro.
88 89 90 91 92 |
# File 'lib/evolvable/gene_cluster.rb', line 88 def apply_cluster(evolvable_class, cluster_name, **_) @cluster_config.each do |name, kw| evolvable_class.gene("#{cluster_name}-#{name}", **kw, cluster: cluster_name) end end |
#gene(name, **opts) ⇒ Object
Defines a gene in the cluster. This is used internally by the cluster to define its component genes.
75 76 77 |
# File 'lib/evolvable/gene_cluster.rb', line 75 def gene(name, **opts) @cluster_config << [name, opts] end |
#inherited(subclass) ⇒ void
This method returns an undefined value.
Ensures that subclasses inherit the cluster configuration.
100 101 102 103 |
# File 'lib/evolvable/gene_cluster.rb', line 100 def inherited(subclass) super subclass.instance_variable_set(:@cluster_config, @cluster_config.dup) end |