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