Class: Ekylibre::Schema::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/ekylibre/schema/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, options = {}) ⇒ Column


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ekylibre/schema/column.rb', line 6

def initialize(name, type, options = {})
  @name = name.to_sym
  @type = type.to_sym
  @options    = options.merge(name: @name, type: @type)
  @null       = !@options[:null].is_a?(FalseClass)
  @default    = @options[:default]
  @limit      = @options[:limit]
  @precision  = @options[:precision]
  @scale      = @options[:scale]
  @references = @options[:references]
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default


4
5
6
# File 'lib/ekylibre/schema/column.rb', line 4

def default
  @default
end

#limitObject (readonly)

Returns the value of attribute limit


4
5
6
# File 'lib/ekylibre/schema/column.rb', line 4

def limit
  @limit
end

#nameObject (readonly)

Returns the value of attribute name


4
5
6
# File 'lib/ekylibre/schema/column.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options


4
5
6
# File 'lib/ekylibre/schema/column.rb', line 4

def options
  @options
end

#precisionObject (readonly)

Returns the value of attribute precision


4
5
6
# File 'lib/ekylibre/schema/column.rb', line 4

def precision
  @precision
end

#referencesObject (readonly)

Returns the value of attribute references


4
5
6
# File 'lib/ekylibre/schema/column.rb', line 4

def references
  @references
end

#scaleObject (readonly)

Returns the value of attribute scale


4
5
6
# File 'lib/ekylibre/schema/column.rb', line 4

def scale
  @scale
end

#typeObject (readonly)

Returns the value of attribute type


4
5
6
# File 'lib/ekylibre/schema/column.rb', line 4

def type
  @type
end

Instance Method Details

#[](value) ⇒ Object


18
19
20
# File 'lib/ekylibre/schema/column.rb', line 18

def [](value)
  @options[value]
end

#null?Boolean


22
23
24
# File 'lib/ekylibre/schema/column.rb', line 22

def null?
  @null
end

#polymorphic?Boolean


30
31
32
# File 'lib/ekylibre/schema/column.rb', line 30

def polymorphic?
  @references.is_a?(String)
end

#references?Boolean


26
27
28
# File 'lib/ekylibre/schema/column.rb', line 26

def references?
  !@references.blank?
end