Class: RareMap::Column
- Inherits:
-
Object
- Object
- RareMap::Column
- Defined in:
- lib/rare_map/column.rb
Overview
RareMap::Column defines a column of a database table.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of this Column.
-
#ref_table ⇒ String
The reference table of this Column.
-
#type ⇒ String
readonly
The type of this Column.
-
#unique ⇒ true, false
The uniqueness of this Column.
Instance Method Summary collapse
-
#foreign_key? ⇒ true, false
Checks if this Column is a foreign key.
-
#initialize(name, type, opts = {}) ⇒ Column
constructor
Creates a Column.
-
#unique? ⇒ true, false
Checks if this Column is unique.
Constructor Details
#initialize(name, type, opts = {}) ⇒ Column
Creates a Column.
22 23 24 25 26 |
# File 'lib/rare_map/column.rb', line 22 def initialize(name, type, opts = {}) @name = name @type = type @unique = opts[:unique] == true end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of this Column.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rare_map/column.rb', line 12 class Column attr_reader :name, :type attr_accessor :unique attr_accessor :ref_table # Creates a Column. # # @param name [String] the name of column # @param type [String] the type of column # @return [Column] a Column object def initialize(name, type, opts = {}) @name = name @type = type @unique = opts[:unique] == true end # Checks if this Column is unique. # # @return [true, false] true if it's unique, false otherwise def unique? @unique end # Checks if this Column is a foreign key. # # @return [true, false] true if it's a foreign key, false otherwise def foreign_key? @ref_table ? true : false end end |
#ref_table ⇒ String
Returns the reference table of this Column.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rare_map/column.rb', line 12 class Column attr_reader :name, :type attr_accessor :unique attr_accessor :ref_table # Creates a Column. # # @param name [String] the name of column # @param type [String] the type of column # @return [Column] a Column object def initialize(name, type, opts = {}) @name = name @type = type @unique = opts[:unique] == true end # Checks if this Column is unique. # # @return [true, false] true if it's unique, false otherwise def unique? @unique end # Checks if this Column is a foreign key. # # @return [true, false] true if it's a foreign key, false otherwise def foreign_key? @ref_table ? true : false end end |
#type ⇒ String (readonly)
Returns the type of this Column.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rare_map/column.rb', line 12 class Column attr_reader :name, :type attr_accessor :unique attr_accessor :ref_table # Creates a Column. # # @param name [String] the name of column # @param type [String] the type of column # @return [Column] a Column object def initialize(name, type, opts = {}) @name = name @type = type @unique = opts[:unique] == true end # Checks if this Column is unique. # # @return [true, false] true if it's unique, false otherwise def unique? @unique end # Checks if this Column is a foreign key. # # @return [true, false] true if it's a foreign key, false otherwise def foreign_key? @ref_table ? true : false end end |
#unique ⇒ true, false
Returns the uniqueness of this Column.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rare_map/column.rb', line 12 class Column attr_reader :name, :type attr_accessor :unique attr_accessor :ref_table # Creates a Column. # # @param name [String] the name of column # @param type [String] the type of column # @return [Column] a Column object def initialize(name, type, opts = {}) @name = name @type = type @unique = opts[:unique] == true end # Checks if this Column is unique. # # @return [true, false] true if it's unique, false otherwise def unique? @unique end # Checks if this Column is a foreign key. # # @return [true, false] true if it's a foreign key, false otherwise def foreign_key? @ref_table ? true : false end end |
Instance Method Details
#foreign_key? ⇒ true, false
Checks if this Column is a foreign key.
38 39 40 |
# File 'lib/rare_map/column.rb', line 38 def foreign_key? @ref_table ? true : false end |
#unique? ⇒ true, false
Checks if this Column is unique.
31 32 33 |
# File 'lib/rare_map/column.rb', line 31 def unique? @unique end |