Class: TableSaw::Manifest
- Inherits:
-
Object
- Object
- TableSaw::Manifest
show all
- Defined in:
- lib/table_saw/manifest.rb
Defined Under Namespace
Classes: HasManyEntry, Table
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config) ⇒ Manifest
Returns a new instance of Manifest.
74
75
76
|
# File 'lib/table_saw/manifest.rb', line 74
def initialize(config)
@config = config
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
72
73
74
|
# File 'lib/table_saw/manifest.rb', line 72
def config
@config
end
|
Class Method Details
.instance ⇒ Object
66
67
68
69
70
|
# File 'lib/table_saw/manifest.rb', line 66
def self.instance
raise ArgumentError, 'Could not find manifest file' unless File.exist?(TableSaw.configuration.manifest)
new(YAML.safe_load_file(TableSaw.configuration.manifest))
end
|
Instance Method Details
#associations ⇒ Object
99
100
101
|
# File 'lib/table_saw/manifest.rb', line 99
def associations
@associations ||= TableSaw::Associations.new(self)
end
|
#foreign_keys ⇒ Object
95
96
97
|
# File 'lib/table_saw/manifest.rb', line 95
def foreign_keys
@foreign_keys ||= config.fetch('foreign_keys', [])
end
|
#has_many ⇒ Object
89
90
91
92
93
|
# File 'lib/table_saw/manifest.rb', line 89
def has_many
@has_many ||= config.fetch('has_many', {}).transform_values do |value|
HasManyEntry.build(value)
end
end
|
#tables ⇒ Object
83
84
85
86
87
|
# File 'lib/table_saw/manifest.rb', line 83
def tables
@tables ||= config['tables'].map { |entry| Table.new(variables, entry) }.each_with_object({}) do |t, memo|
memo[t.name] = t
end
end
|