Class: BqGuess::Schema

Inherits:
Hash
  • Object
show all
Defined in:
lib/bq_guess/schema.rb

Instance Method Summary collapse

Instance Method Details

#as_schemaObject



7
8
9
# File 'lib/bq_guess/schema.rb', line 7

def as_schema
  values.map(&:as_schema)
end

#merge!(other) ⇒ Object



11
12
13
14
# File 'lib/bq_guess/schema.rb', line 11

def merge!(other)
  _merge!(other)
  set_nullable(other)
end

#null?(key) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/bq_guess/schema.rb', line 16

def null?(key)
  !key?(key) || self[key].is_a?(Fields::Null)
end

#nullable!Object



20
21
22
# File 'lib/bq_guess/schema.rb', line 20

def nullable!
  each_value(&:nullable!)
end

#repeated?(key) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/bq_guess/schema.rb', line 24

def repeated?(key)
  !!self[key]&.repeated?
end

#to_aObject



28
29
30
# File 'lib/bq_guess/schema.rb', line 28

def to_a
  values.map(&:to_hash)
end