Class: MySQLExpectations::KeyField

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql_expectations/key_field.rb

Overview

An index field has a field name, length, and order (aka order)

Constant Summary collapse

ORDER_ASC =
:asc
ORDER_DESC =
:desc
VALID_ORDERINGS =
[ORDER_ASC, ORDER_DESC]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, order = nil, length = nil) ⇒ KeyField

Returns a new instance of KeyField.



16
17
18
19
20
# File 'lib/mysql_expectations/key_field.rb', line 16

def initialize(name, order = nil, length = nil)
  @name = name
  @order = validate_order(order)
  @length = validate_length(length)
end

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length.



9
10
11
# File 'lib/mysql_expectations/key_field.rb', line 9

def length
  @length
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/mysql_expectations/key_field.rb', line 9

def name
  @name
end

#orderObject (readonly)

Returns the value of attribute order.



9
10
11
# File 'lib/mysql_expectations/key_field.rb', line 9

def order
  @order
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/mysql_expectations/key_field.rb', line 22

def ==(other)
  other.name == @name && other.length == @length && other.order == @order
end

#to_sObject



26
27
28
# File 'lib/mysql_expectations/key_field.rb', line 26

def to_s
  "{ '#{name}', #{order_to_s}, #{length_to_s} }"
end