Class: ActiveRecordInlineSchema::Config::Index
- Inherits:
-
Object
- Object
- ActiveRecordInlineSchema::Config::Index
- Defined in:
- lib/active_record_inline_schema/config/index.rb
Instance Attribute Summary collapse
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#initial_options ⇒ Object
readonly
Returns the value of attribute initial_options.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(parent, column_name, options) ⇒ Index
constructor
A new instance of Index.
- #name ⇒ Object
- #options ⇒ Object
Constructor Details
#initialize(parent, column_name, options) ⇒ Index
Returns a new instance of Index.
12 13 14 15 16 17 |
# File 'lib/active_record_inline_schema/config/index.rb', line 12 def initialize(parent, column_name, ) @parent = parent @column_name = column_name @initial_options = .symbolize_keys @name_mutex = ::Mutex.new end |
Instance Attribute Details
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
6 7 8 |
# File 'lib/active_record_inline_schema/config/index.rb', line 6 def column_name @column_name end |
#initial_options ⇒ Object (readonly)
Returns the value of attribute initial_options.
7 8 9 |
# File 'lib/active_record_inline_schema/config/index.rb', line 7 def @initial_options end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
5 6 7 |
# File 'lib/active_record_inline_schema/config/index.rb', line 5 def parent @parent end |
Instance Method Details
#eql?(other) ⇒ Boolean
37 38 39 |
# File 'lib/active_record_inline_schema/config/index.rb', line 37 def eql?(other) other.is_a?(self.class) and parent == other.parent and column_name == other.column_name and == other. end |
#hash ⇒ Object
41 42 43 |
# File 'lib/active_record_inline_schema/config/index.rb', line 41 def hash [parent, column_name, ].hash end |
#name ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_record_inline_schema/config/index.rb', line 19 def name @name || @name_mutex.synchronize do @name ||= begin max_name_length = connection.index_name_length prototype = connection.index_name model.table_name, :column => column_name if prototype.length < max_name_length prototype else prototype[0..(max_name_length-11)] + ::Zlib.crc32(prototype).to_s end end end end |
#options ⇒ Object
33 34 35 |
# File 'lib/active_record_inline_schema/config/index.rb', line 33 def @initial_options.merge(:column_name => column_name, :name => name) end |