Class: CreateTable::ColumnNameBasedCollection

Inherits:
Delegator
  • Object
show all
Defined in:
lib/create_table/column_name_based_collection.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.createObject



5
6
7
# File 'lib/create_table/column_name_based_collection.rb', line 5

def create
  new([])
end

Instance Method Details

#[](column_names) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/create_table/column_name_based_collection.rb', line 18

def [](column_names)
  return if column_names.nil?
  k = [column_names].flatten
  retval = @items.select { |i| i.column_names == k }
  raise "oops #{k.inspect}: #{retval.map(&:column_names).inspect}" if retval.length > 1
  retval.first
end

#__getobj__Object



10
11
12
# File 'lib/create_table/column_name_based_collection.rb', line 10

def __getobj__
  @items
end

#__setobj__(items) ⇒ Object



14
15
16
# File 'lib/create_table/column_name_based_collection.rb', line 14

def __setobj__(items)
  @items = items
end