Class: BigShift::Schema
- Defined in:
- lib/big_shift/models/schema.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#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.
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
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
4 5 6 |
# File 'lib/big_shift/models/schema.rb', line 4 def fields @fields end |
#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
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 |