Class: BigShift::Schema
- Defined in:
- lib/big_shift/models/schema.rb
Instance Attribute Summary collapse
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #add_field(field_name, field_type) ⇒ Object
- #as_json(json_state = nil) ⇒ Object
-
#initialize(table_name) ⇒ Schema
constructor
A new instance of Schema.
Methods inherited from BaseModel
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_name ⇒ Object (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 |