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.



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

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

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



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

def fields
  @fields
end

#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



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

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

#as_json(json_state = nil) ⇒ Object



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

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