class Model
Public Class Methods
new(name)
click to toggle source
# File lib/model-visualizer/model.rb, line 5 def initialize(name) @name = name @belongs_to = Array.new @has_one = Array.new @has_many = Array.new @has_and_belongs_to_many = Array.new @integer_attributes = Array.new @string_attributes = Array.new @primary_key_attributes = Array.new @text_attributes = Array.new @float_attributes = Array.new @decimal_attributes = Array.new @datetime_attributes = Array.new @timestamp_attributes = Array.new @time_attributes = Array.new @date_attributes = Array.new @binary_attributes = Array.new @boolean_attributes = Array.new @foreign_keys = Array.new end
Public Instance Methods
add_belongs_to(model)
click to toggle source
# File lib/model-visualizer/model.rb, line 26 def add_belongs_to(model) @belongs_to << model end
add_binary_attribute(binary)
click to toggle source
# File lib/model-visualizer/model.rb, line 82 def add_binary_attribute(binary) @binary_attributes << binary end
add_boolean_attribute(boolean)
click to toggle source
# File lib/model-visualizer/model.rb, line 86 def add_boolean_attribute(boolean) @boolean_attributes << boolean end
add_date_attribute(date)
click to toggle source
# File lib/model-visualizer/model.rb, line 78 def add_date_attribute(date) @date_attributes << date end
add_datetime_attribute(datetime)
click to toggle source
# File lib/model-visualizer/model.rb, line 66 def add_datetime_attribute(datetime) @datetime_attributes << datetime end
add_decimal_attribute(decimal)
click to toggle source
# File lib/model-visualizer/model.rb, line 62 def add_decimal_attribute(decimal) @decimal_attributes << decimal end
add_float_attribute(float)
click to toggle source
# File lib/model-visualizer/model.rb, line 58 def add_float_attribute(float) @float_attributes << float end
add_foreign_key_attribute(key)
click to toggle source
# File lib/model-visualizer/model.rb, line 90 def add_foreign_key_attribute(key) @foreign_keys << key end
add_has_and_belongs_to_many(model)
click to toggle source
# File lib/model-visualizer/model.rb, line 38 def add_has_and_belongs_to_many(model) @has_and_belongs_to_many << model end
add_has_many(model)
click to toggle source
# File lib/model-visualizer/model.rb, line 34 def add_has_many(model) @has_many << model end
add_has_one(model)
click to toggle source
# File lib/model-visualizer/model.rb, line 30 def add_has_one(model) @has_one << model end
add_integer_attribute(integer)
click to toggle source
# File lib/model-visualizer/model.rb, line 42 def add_integer_attribute(integer) @integer_attributes << integer end
add_primary_key_attribute(primary_key)
click to toggle source
# File lib/model-visualizer/model.rb, line 50 def add_primary_key_attribute(primary_key) @primary_key_attributes << primary_key end
add_string_attribute(string)
click to toggle source
# File lib/model-visualizer/model.rb, line 46 def add_string_attribute(string) @string_attributes << string end
add_text_attribute(text)
click to toggle source
# File lib/model-visualizer/model.rb, line 54 def add_text_attribute(text) @text_attributes << text end
add_time_attribute(time)
click to toggle source
# File lib/model-visualizer/model.rb, line 74 def add_time_attribute(time) @time_attributes << time end
add_timestamp_attribute(timestamp)
click to toggle source
# File lib/model-visualizer/model.rb, line 70 def add_timestamp_attribute(timestamp) @timestamp_attributes << timestamp end
to_json(options = {})
click to toggle source
# File lib/model-visualizer/model.rb, line 94 def to_json(options = {}) json = { 'name' => @name, 'associations' => {}, 'schema_info' => {} } if not @belongs_to.empty? json['associations']['belongs_to'] = @belongs_to end if not @has_one.empty? json['associations']['has_one'] = @has_one end if not @has_many.empty? json['associations']['has_many'] = @has_many end if not @has_and_belongs_to_many.empty? json['associations']['has_and_belongs_to_many'] = @has_and_belongs_to_many end if not @integer_attributes.empty? json['schema_info']['integer_attributes'] = @integer_attributes end if not @string_attributes.empty? json['schema_info']['string_attributes'] = @string_attributes end if not @primary_key_attributes.empty? json['schema_info']['primary_key_attributes'] = @primary_key_attributes end if not @text_attributes.empty? json['schema_info']['text_attributes'] = @text_attributes end if not @float_attributes.empty? json['schema_info']['float_attributes'] = @float_attributes end if not @decimal_attributes.empty? json['schema_info']['decimal_attributes'] = @decimal_attributes end if not @date_attributes.empty? json['schema_info']['date_attributes'] = @date_attributes end if not @datetime_attributes.empty? json['schema_info']['datetime_attributes'] = @datetime_attributes end if not @time_attributes.empty? json['schema_info']['time_attributes'] = @time_attributes end if not @timestamp_attributes.empty? json['schema_info']['timestamp_attributes'] = @timestamp_attributes end if not @binary_attributes.empty? json['schema_info']['binary_attributes'] = @binary_attributes end if not @boolean_attributes.empty? json['schema_info']['boolean_attributes'] = @boolean_attributes end if not @foreign_keys.empty? json['schema_info']['foreign_keys'] = @foreign_keys end json.to_json end