Class: TypedDag::Configuration
- Inherits:
-
Object
- Object
- TypedDag::Configuration
- Defined in:
- lib/typed_dag/configuration.rb
Class Method Summary collapse
Instance Method Summary collapse
- #count_column ⇒ Object
- #edge_class ⇒ Object
- #edge_class_name ⇒ Object
- #edge_table_name ⇒ Object
- #from_column ⇒ Object
-
#initialize(config) ⇒ Configuration
constructor
A new instance of Configuration.
- #node_class ⇒ Object
- #node_class_name ⇒ Object
- #node_table_name ⇒ Object
- #to_column ⇒ Object
- #type_columns ⇒ Object
- #types ⇒ Object
Constructor Details
#initialize(config) ⇒ Configuration
Returns a new instance of Configuration.
23 24 25 |
# File 'lib/typed_dag/configuration.rb', line 23 def initialize(config) self.config = config end |
Class Method Details
.[](class_name) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/typed_dag/configuration.rb', line 8 def self.[](class_name) class_name = class_name.to_s @instances.detect do |config| config.node_class_name == class_name || config.edge_class_name == class_name end end |
.each ⇒ Object
17 18 19 20 21 |
# File 'lib/typed_dag/configuration.rb', line 17 def self.each @instances.each do |instance| yield instance end end |
.set(config) ⇒ Object
2 3 4 5 6 |
# File 'lib/typed_dag/configuration.rb', line 2 def self.set(config) config = [config] unless config.is_a?(Array) @instances = config.map { |conf| new(conf) } end |
Instance Method Details
#count_column ⇒ Object
59 60 61 |
# File 'lib/typed_dag/configuration.rb', line 59 def count_column config[:count_column] || 'count' end |
#edge_class ⇒ Object
43 44 45 |
# File 'lib/typed_dag/configuration.rb', line 43 def edge_class edge_class_name.constantize end |
#edge_class_name ⇒ Object
39 40 41 |
# File 'lib/typed_dag/configuration.rb', line 39 def edge_class_name config[:edge_class_name] end |
#edge_table_name ⇒ Object
47 48 49 |
# File 'lib/typed_dag/configuration.rb', line 47 def edge_table_name edge_class.table_name end |
#from_column ⇒ Object
51 52 53 |
# File 'lib/typed_dag/configuration.rb', line 51 def from_column config[:from_column] || 'from_id' end |
#node_class ⇒ Object
31 32 33 |
# File 'lib/typed_dag/configuration.rb', line 31 def node_class node_class_name.constantize end |
#node_class_name ⇒ Object
27 28 29 |
# File 'lib/typed_dag/configuration.rb', line 27 def node_class_name config[:node_class_name] end |
#node_table_name ⇒ Object
35 36 37 |
# File 'lib/typed_dag/configuration.rb', line 35 def node_table_name node_class.table_name end |
#to_column ⇒ Object
55 56 57 |
# File 'lib/typed_dag/configuration.rb', line 55 def to_column config[:to_column] || 'to_id' end |
#type_columns ⇒ Object
67 68 69 |
# File 'lib/typed_dag/configuration.rb', line 67 def type_columns types.keys end |
#types ⇒ Object
63 64 65 |
# File 'lib/typed_dag/configuration.rb', line 63 def types config[:types] || default_types end |