Class: BigShift::Schema

Inherits:
BaseModel show all
Defined in:
lib/big_shift/models/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_json

Constructor Details

#initialize(table_name) ⇒ Schema

Returns a new instance of Schema.



5
6
7
8
# File 'lib/big_shift/models/schema.rb', line 5

def initialize(table_name)
  @table_name = table_name
  @fields = []
end

Instance Attribute Details

#table_nameObject (readonly)

Returns the value of attribute table_name.



3
4
5
# File 'lib/big_shift/models/schema.rb', line 3

def table_name
  @table_name
end

Instance Method Details

#add_field(field_name, field_type) ⇒ Object



10
11
12
13
# File 'lib/big_shift/models/schema.rb', line 10

def add_field(field_name, field_type)
  @fields << TableField.new(field_name, field_type)
  self
end

#as_json(json_state = nil) ⇒ Object



15
16
17
18
19
# File 'lib/big_shift/models/schema.rb', line 15

def as_json(json_state = nil)
  {
    'fields' => @fields,
  }
end