class Record
An record class to represent an ActiveRecord table
Constants
- VALID_TYPES
Array with valid ActiveRecord datatypes
Attributes
columns[RW]
name[R]
Instance variable: name of the Model using table
Public Class Methods
new(name)
click to toggle source
Record
constructor to initialize Record
with name
# File lib/active_recorder/record.rb, line 13 def initialize(name) # Validate name fail ArgumentError, 'Name cannot be nil!' if name.nil? fail ArgumentError, 'Name cannot be empty!' if name.empty? # Initialize name and columns @name = name @columns = {} end
Public Instance Methods
add_column(col, type)
click to toggle source
Adds a column to record
# File lib/active_recorder/record.rb, line 23 def add_column(col, type) # Check whether the column added is a valid ActiveRecord type fail ArgumentError, 'Invalid ActiveRecord datatype!' unless VALID_TYPES.include?(type) # Add column to record @columns[col] = type end