Class: ActiveRecordInlineSchema::Config::Column
- Inherits:
-
Object
- Object
- ActiveRecordInlineSchema::Config::Column
- Defined in:
- lib/active_record_inline_schema/config/column.rb
Constant Summary collapse
- DEFAULT_TYPE =
:string
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(parent, name, options) ⇒ Column
constructor
A new instance of Column.
- #inject(table_definition) ⇒ Object
Constructor Details
#initialize(parent, name, options) ⇒ Column
Returns a new instance of Column.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_record_inline_schema/config/column.rb', line 9 def initialize(parent, name, ) @parent = parent @name = name.to_s = .symbolize_keys if .slice(:precision, :scale).keys.length == 1 raise ::ArgumentError, %{[active_record_inline_schema] :precision and :scale must always be specified together} end @type = .fetch(:type, DEFAULT_TYPE).to_sym @options = .except :type, :name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/active_record_inline_schema/config/column.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/active_record_inline_schema/config/column.rb', line 7 def @options end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/active_record_inline_schema/config/column.rb', line 4 def parent @parent end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/active_record_inline_schema/config/column.rb', line 6 def type @type end |
Instance Method Details
#eql?(other) ⇒ Boolean
28 29 30 |
# File 'lib/active_record_inline_schema/config/column.rb', line 28 def eql?(other) other.is_a?(self.class) and parent == other.parent and name == other.name and == other. end |
#hash ⇒ Object
32 33 34 |
# File 'lib/active_record_inline_schema/config/column.rb', line 32 def hash [parent, name, ].hash end |
#inject(table_definition) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/active_record_inline_schema/config/column.rb', line 20 def inject(table_definition) if type != :primary_key and table_definition.respond_to?(type) table_definition.send type, name, else table_definition.column name, type, end end |