Class: TableSaw::Manifest::Table
- Inherits:
-
Object
- Object
- TableSaw::Manifest::Table
- Defined in:
- lib/table_saw/manifest.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
- #has_many ⇒ Object
-
#initialize(variables, config) ⇒ Table
constructor
A new instance of Table.
- #partial? ⇒ Boolean
- #query ⇒ Object
- #table ⇒ Object (also: #name)
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
#config ⇒ Object (readonly)
Returns the value of attribute config.
38 39 40 |
# File 'lib/table_saw/manifest.rb', line 38 def config @config end |
#variables ⇒ Object (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_many ⇒ Object
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
57 58 59 |
# File 'lib/table_saw/manifest.rb', line 57 def partial? config.key?('query') end |
#query ⇒ Object
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 |
#table ⇒ Object Also known as: name
45 46 47 |
# File 'lib/table_saw/manifest.rb', line 45 def table config['table'] end |