Class: TableSaw::DependencyGraph::AddDirective

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_name, ids: [], partial: true, has_many: {}) ⇒ AddDirective

Returns a new instance of AddDirective.



9
10
11
12
13
14
# File 'lib/table_saw/dependency_graph/add_directive.rb', line 9

def initialize(table_name, ids: [], partial: true, has_many: {})
  @table_name = table_name
  @ids = ids
  @partial = partial
  @has_many = has_many
end

Instance Attribute Details

#has_manyObject (readonly)

Returns the value of attribute has_many.



6
7
8
# File 'lib/table_saw/dependency_graph/add_directive.rb', line 6

def has_many
  @has_many
end

#idsObject

Returns the value of attribute ids.



7
8
9
# File 'lib/table_saw/dependency_graph/add_directive.rb', line 7

def ids
  @ids
end

#partialObject (readonly) Also known as: partial?

Returns the value of attribute partial.



6
7
8
# File 'lib/table_saw/dependency_graph/add_directive.rb', line 6

def partial
  @partial
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



6
7
8
# File 'lib/table_saw/dependency_graph/add_directive.rb', line 6

def table_name
  @table_name
end

Instance Method Details

#primary_keyObject



26
27
28
# File 'lib/table_saw/dependency_graph/add_directive.rb', line 26

def primary_key
  TableSaw.schema_cache.primary_keys(table_name)
end

#queryable?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/table_saw/dependency_graph/add_directive.rb', line 22

def queryable?
  !partial || selectable?
end

#selectable?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/table_saw/dependency_graph/add_directive.rb', line 18

def selectable?
  partial? && Array(ids).size.positive?
end