Module: Cql::Model::SchemaMethods::ClassMethods

Defined in:
lib/cql/model/schema_methods.rb

Instance Method Summary collapse

Instance Method Details

#column(attribute_name, ruby_class, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/cql/model/schema_methods.rb', line 25

def column(attribute_name, ruby_class, options = {})
  column_name = options[:column_name] || attribute_name

  @columns ||= {}
  @columns[column_name.to_sym] = {
    attribute_name: attribute_name.to_sym,
    klass: ruby_class.to_s.constantize
  }.merge(options)
end

#columnsObject



17
18
19
# File 'lib/cql/model/schema_methods.rb', line 17

def columns
  @columns ||= {}
end

#primary_key(key_name = nil) ⇒ Object



21
22
23
# File 'lib/cql/model/schema_methods.rb', line 21

def primary_key(key_name = nil)
  @primary_key ||= key_name.nil? ? 'id' : key_name.to_s
end

#table_nameObject



13
14
15
# File 'lib/cql/model/schema_methods.rb', line 13

def table_name
  @table_name ||= self.model_name.plural
end