Class: Automigration::DbColumn
- Inherits:
-
Struct
- Object
- Struct
- Automigration::DbColumn
- Defined in:
- lib/automigration/db_column.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name_, type_, options_) ⇒ DbColumn
constructor
A new instance of DbColumn.
- #the_same?(other) ⇒ Boolean
- #to_options ⇒ Object
Constructor Details
#initialize(name_, type_, options_) ⇒ DbColumn
Returns a new instance of DbColumn.
3 4 5 6 |
# File 'lib/automigration/db_column.rb', line 3 def initialize(name_, type_, ) super .assert_valid_keys(:default, :null, :limit, :scale, :precision) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/automigration/db_column.rb', line 2 def name @name end |
#options ⇒ Object
Returns the value of attribute options
2 3 4 |
# File 'lib/automigration/db_column.rb', line 2 def end |
#type ⇒ Object
Returns the value of attribute type
2 3 4 |
# File 'lib/automigration/db_column.rb', line 2 def type @type end |
Class Method Details
.from_activerecord_column(column) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/automigration/db_column.rb', line 8 def self.from_activerecord_column(column) out = DbColumn.new(column.name.to_sym, column.type.to_sym, { :default => column.default, :null => column.null, :limit => column.limit, :scale => column.scale, :precision => column.precision }) end |
Instance Method Details
#the_same?(other) ⇒ Boolean
18 19 20 |
# File 'lib/automigration/db_column.rb', line 18 def the_same?(other) (__to_array <=> other.send(:__to_array)) == 0 end |
#to_options ⇒ Object
22 23 24 |
# File 'lib/automigration/db_column.rb', line 22 def .reject{|k, v| k != :default && v.nil?} end |