Class: Mimi::DB::Dictate::SchemaDefinition::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/mimi/db/dictate/schema_definition.rb

Overview

Represents an index in schema definition

Constant Summary collapse

DEFAULTS =
{
  unique: false
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(columns, params) ⇒ Index

Creates an Index object

Parameters:

  • columns (Array<String,Symbol>)
  • params (Hash)


149
150
151
152
153
# File 'lib/mimi/db/dictate/schema_definition.rb', line 149

def initialize(columns, params)
  @name = params[:name]
  @columns = columns.map(&:to_sym)
  @params = DEFAULTS.merge(params)
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



142
143
144
# File 'lib/mimi/db/dictate/schema_definition.rb', line 142

def columns
  @columns
end

#nameObject (readonly)

Returns the value of attribute name.



142
143
144
# File 'lib/mimi/db/dictate/schema_definition.rb', line 142

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



142
143
144
# File 'lib/mimi/db/dictate/schema_definition.rb', line 142

def params
  @params
end

Instance Method Details

#to_hObject



155
156
157
158
159
160
161
# File 'lib/mimi/db/dictate/schema_definition.rb', line 155

def to_h
  {
    name: name,
    columns: columns,
    params: params.dup
  }
end