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.



10
11
12
13
# File 'lib/table_saw/manifest.rb', line 10

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/table_saw/manifest.rb', line 8

def config
  @config
end

#variablesObject (readonly)

Returns the value of attribute variables.



8
9
10
# File 'lib/table_saw/manifest.rb', line 8

def variables
  @variables
end

Instance Method Details

#has_manyObject

rubocop:disable Naming/PredicateName



30
31
32
# File 'lib/table_saw/manifest.rb', line 30

def has_many
  config.fetch('has_many', [])
end

#queryObject



21
22
23
24
25
26
27
# File 'lib/table_saw/manifest.rb', line 21

def query
  if config['query']
    format(config['query'], variables.transform_keys(&:to_sym))
  else
    "select id from #{table}"
  end
end

#tableObject Also known as: name



15
16
17
# File 'lib/table_saw/manifest.rb', line 15

def table
  config['table']
end