Module: Dagnabit::Vertex::Settings
- Included in:
- Associations, Connectivity
- Defined in:
- lib/dagnabit/vertex/settings.rb
Overview
Contains parameters that can be customized on a per-vertex-model basis.
Instance Attribute Summary collapse
-
#edge_model_name ⇒ String
The name of this vertex’s edge model.
Instance Method Summary collapse
-
#connected_by(edge_model_name) ⇒ void
Sets the name of the edge model associated with a vertex.
-
#edge_model ⇒ Class
The edge model associated with a vertex model.
-
#edge_table ⇒ String
The edge table used by connectivity queries.
-
#inherited(subclass) ⇒ Object
This callback ensures that whenever a class that extends Settings is inherited, the settings for the superclass are passed to the subclass.
Instance Attribute Details
#edge_model_name ⇒ String
The name of this vertex’s edge model.
11 12 13 |
# File 'lib/dagnabit/vertex/settings.rb', line 11 def edge_model_name @edge_model_name end |
Instance Method Details
#connected_by(edge_model_name) ⇒ void
This method returns an undefined value.
Sets the name of the edge model associated with a vertex.
#edge_model uses ActiveSupport’s ‘constantize` method to look up the model from `edge_model_name`.
39 40 41 |
# File 'lib/dagnabit/vertex/settings.rb', line 39 def connected_by(edge_model_name) self.edge_model_name = edge_model_name end |
#edge_model ⇒ Class
The edge model associated with a vertex model.
17 18 19 |
# File 'lib/dagnabit/vertex/settings.rb', line 17 def edge_model edge_model_name.constantize end |
#edge_table ⇒ String
The edge table used by connectivity queries. Equivalent to
edge_model.table_name
27 28 29 |
# File 'lib/dagnabit/vertex/settings.rb', line 27 def edge_table edge_model.table_name end |
#inherited(subclass) ⇒ Object
This callback ensures that whenever a class that extends Settings is inherited, the settings for the superclass are passed to the subclass.
This callback executes any previously-defined definitions of ‘inherited` beforee executing its own code.
51 52 53 54 |
# File 'lib/dagnabit/vertex/settings.rb', line 51 def inherited(subclass) super subclass.connected_by(edge_model_name) end |