Class: ActiveRecordSpannerAdapter::Table::Column
- Inherits:
-
Object
- Object
- ActiveRecordSpannerAdapter::Table::Column
- Defined in:
- lib/activerecord_spanner_adapter/table/column.rb
Instance Attribute Summary collapse
-
#allow_commit_timestamp ⇒ Object
Returns the value of attribute allow_commit_timestamp.
-
#default ⇒ Object
Returns the value of attribute default.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#name ⇒ Object
Returns the value of attribute name.
- #nullable ⇒ Object
-
#ordinal_position ⇒ Object
Returns the value of attribute ordinal_position.
-
#primary_key ⇒ Object
Returns the value of attribute primary_key.
-
#table_name ⇒ Object
Returns the value of attribute table_name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(table_name, name, type, limit: nil, ordinal_position: nil, nullable: true, allow_commit_timestamp: nil, default: nil) ⇒ Column
constructor
A new instance of Column.
- #options ⇒ Object
- #spanner_type ⇒ Object
Constructor Details
#initialize(table_name, name, type, limit: nil, ordinal_position: nil, nullable: true, allow_commit_timestamp: nil, default: nil) ⇒ Column
Returns a new instance of Column.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 14 def initialize \ table_name, name, type, limit: nil, ordinal_position: nil, nullable: true, allow_commit_timestamp: nil, default: nil @table_name = table_name.to_s @name = name.to_s @type = type @limit = limit @nullable = nullable != false @ordinal_position = ordinal_position @allow_commit_timestamp = @default = default @primary_key = false end |
Instance Attribute Details
#allow_commit_timestamp ⇒ Object
Returns the value of attribute allow_commit_timestamp.
10 11 12 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 10 def @allow_commit_timestamp end |
#default ⇒ Object
Returns the value of attribute default.
10 11 12 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 10 def default @default end |
#limit ⇒ Object
Returns the value of attribute limit.
10 11 12 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 10 def limit @limit end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 10 def name @name end |
#nullable ⇒ Object
34 35 36 37 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 34 def nullable return false if primary_key @nullable end |
#ordinal_position ⇒ Object
Returns the value of attribute ordinal_position.
10 11 12 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 10 def ordinal_position @ordinal_position end |
#primary_key ⇒ Object
Returns the value of attribute primary_key.
10 11 12 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 10 def primary_key @primary_key end |
#table_name ⇒ Object
Returns the value of attribute table_name.
10 11 12 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 10 def table_name @table_name end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 10 def type @type end |
Instance Method Details
#options ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 44 def { limit: limit, null: nullable, allow_commit_timestamp: }.delete_if { |_, v| v.nil? } end |
#spanner_type ⇒ Object
39 40 41 42 |
# File 'lib/activerecord_spanner_adapter/table/column.rb', line 39 def spanner_type return "#{type}(#{limit || 'MAX'})" if limit_allowed? type end |