Class: Migsupo::Schema::ColumnDefinition
- Inherits:
-
Object
- Object
- Migsupo::Schema::ColumnDefinition
- Defined in:
- lib/migsupo/schema/column_definition.rb
Constant Summary collapse
- COMPARABLE_OPTIONS =
%i[null default limit precision scale comment].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #comparable_options ⇒ Object
- #hash ⇒ Object
-
#initialize(name:, type:, options: {}) ⇒ ColumnDefinition
constructor
A new instance of ColumnDefinition.
- #to_h ⇒ Object
Constructor Details
#initialize(name:, type:, options: {}) ⇒ ColumnDefinition
Returns a new instance of ColumnDefinition.
8 9 10 11 12 13 |
# File 'lib/migsupo/schema/column_definition.rb', line 8 def initialize(name:, type:, options: {}) @name = name.to_s @type = type.to_sym @options = () freeze end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/migsupo/schema/column_definition.rb', line 4 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/migsupo/schema/column_definition.rb', line 4 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/migsupo/schema/column_definition.rb', line 4 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
15 16 17 18 19 |
# File 'lib/migsupo/schema/column_definition.rb', line 15 def ==(other) return false unless other.is_a?(ColumnDefinition) name == other.name && type == other.type && == other. end |
#comparable_options ⇒ Object
31 32 33 |
# File 'lib/migsupo/schema/column_definition.rb', line 31 def .slice(*COMPARABLE_OPTIONS).reject { |_, v| v.nil? } end |
#hash ⇒ Object
23 24 25 |
# File 'lib/migsupo/schema/column_definition.rb', line 23 def hash [name, type, ].hash end |
#to_h ⇒ Object
27 28 29 |
# File 'lib/migsupo/schema/column_definition.rb', line 27 def to_h { name: name, type: type, options: } end |