Module: Dagnabit::Activation
- Defined in:
- lib/dagnabit/activation.rb
Overview
Class methods for mixing in (“activating”) dag functionality.
Instance Method Summary collapse
-
#acts_as_dag_link(options = {}) ⇒ Object
Marks an ActiveRecord model as a link model.
-
#acts_as_dag_node_linked_by(link_class_name) ⇒ Object
Adds convenience methods to dag nodes.
Instance Method Details
#acts_as_dag_link(options = {}) ⇒ Object
Marks an ActiveRecord model as a link model.
Supported options
- :ancestor_id_column
-
Name of the column in the link tables that will hold the ID of the ancestor object. Defaults to
ancestor_id
. - :descendant_id_column
-
Name of the column in the link tables that will hold the ID of the descendant object. Defaults to
descendant_id
. - :transitive_closure_table_name
-
Name of the table that will hold the tuples comprising the transitive closure of the dag. Defaults to the edge model’s table name affixed by “
_transitive_closure_tuples
”. - :transitive_closure_class_name
-
Name of the generated class that will represent tuples in the transitive closure tuple table. This class is created inside the link model class. Defaults to
TransitiveClosureLink
.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dagnabit/activation.rb', line 26 def acts_as_dag_link( = {}) extend Dagnabit::Link::Configuration configure_acts_as_dag_link() extend Dagnabit::Link::TransitiveClosureLinkModel generate_transitive_closure_link_model() extend Dagnabit::Link::ClassMethods extend Dagnabit::Link::Associations extend Dagnabit::Link::NamedScopes extend Dagnabit::Link::Validations include Dagnabit::Link::CyclePrevention include Dagnabit::Link::TransitiveClosureRecalculation end |
#acts_as_dag_node_linked_by(link_class_name) ⇒ Object
Adds convenience methods to dag nodes.
Strictly speaking, it’s not necessary to call this method inside classes you want to act as nodes. acts_as_dag_node_linked_by
merely provides convenience methods for finding and traversing links from/to this node.
The link_class_name
parameter determines the the link model to be used for nodes of this type.
51 52 53 54 55 56 57 58 |
# File 'lib/dagnabit/activation.rb', line 51 def acts_as_dag_node_linked_by(link_class_name) extend Dagnabit::Node::Configuration configure_acts_as_dag_node(link_class_name) extend Dagnabit::Node::ClassMethods extend Dagnabit::Node::Associations include Dagnabit::Node::Neighbors end |