Class: ZodRails::Introspection::ColumnInfo
- Inherits:
-
Object
- Object
- ZodRails::Introspection::ColumnInfo
- Defined in:
- lib/zod_rails/introspection/column_info.rb
Instance Attribute Summary collapse
-
#has_default ⇒ Object
readonly
Returns the value of attribute has_default.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nullable ⇒ Object
readonly
Returns the value of attribute nullable.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name:, type:, nullable:, has_default:) ⇒ ColumnInfo
constructor
A new instance of ColumnInfo.
Constructor Details
#initialize(name:, type:, nullable:, has_default:) ⇒ ColumnInfo
Returns a new instance of ColumnInfo.
8 9 10 11 12 13 14 |
# File 'lib/zod_rails/introspection/column_info.rb', line 8 def initialize(name:, type:, nullable:, has_default:) @name = name @type = type @nullable = nullable @has_default = has_default freeze end |
Instance Attribute Details
#has_default ⇒ Object (readonly)
Returns the value of attribute has_default.
6 7 8 |
# File 'lib/zod_rails/introspection/column_info.rb', line 6 def has_default @has_default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/zod_rails/introspection/column_info.rb', line 6 def name @name end |
#nullable ⇒ Object (readonly)
Returns the value of attribute nullable.
6 7 8 |
# File 'lib/zod_rails/introspection/column_info.rb', line 6 def nullable @nullable end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/zod_rails/introspection/column_info.rb', line 6 def type @type end |
Class Method Details
.from_column(column) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/zod_rails/introspection/column_info.rb', line 16 def self.from_column(column) new( name: column.name, type: column.type, nullable: column.null, has_default: !column.default.nil? ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
25 26 27 28 29 30 31 |
# File 'lib/zod_rails/introspection/column_info.rb', line 25 def ==(other) other.is_a?(self.class) && name == other.name && type == other.type && nullable == other.nullable && has_default == other.has_default end |
#hash ⇒ Object
34 35 36 |
# File 'lib/zod_rails/introspection/column_info.rb', line 34 def hash [self.class, name, type, nullable, has_default].hash end |