Module: FileDb::Columns
- Included in:
- Model
- Defined in:
- lib/file_db/columns.rb
Instance Method Summary collapse
Instance Method Details
#column_index(column) ⇒ Object
22 23 24 |
# File 'lib/file_db/columns.rb', line 22 def column_index column @columns.index column end |
#columns(*names) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/file_db/columns.rb', line 4 def columns *names return @columns if names.empty? names.delete(:id) @columns = [:id] + names @columns_hash = {} @columns.each do |name| @columns_hash[name] = true define_method name do instance_variable_get "@#{name}" end define_method "#{name}=" do |new_val| instance_variable_set "@#{name}", new_val end end end |
#columns_hash ⇒ Object
26 27 28 |
# File 'lib/file_db/columns.rb', line 26 def columns_hash @columns_hash end |