Class: TableSaw::Manifest::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/table_saw/manifest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variables, config) ⇒ Table

Returns a new instance of Table.



40
41
42
43
# File 'lib/table_saw/manifest.rb', line 40

def initialize(variables, config)
  @variables = variables
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



38
39
40
# File 'lib/table_saw/manifest.rb', line 38

def config
  @config
end

#variablesObject (readonly)

Returns the value of attribute variables.



38
39
40
# File 'lib/table_saw/manifest.rb', line 38

def variables
  @variables
end

Instance Method Details

#has_manyObject



61
62
63
# File 'lib/table_saw/manifest.rb', line 61

def has_many
  config.fetch('has_many', {}).then { |config| HasManyEntry.build(config) }
end

#partial?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/table_saw/manifest.rb', line 57

def partial?
  config.key?('query')
end

#queryObject



51
52
53
54
55
# File 'lib/table_saw/manifest.rb', line 51

def query
  return unless partial?

  format(config['query'], variables.transform_keys(&:to_sym))
end

#tableObject Also known as: name



45
46
47
# File 'lib/table_saw/manifest.rb', line 45

def table
  config['table']
end