module Schema

Public Instance Methods

attributes() click to toggle source
# File lib/bloc_record/schema.rb, line 13
def attributes
  columns - ["id"]
end
columns() click to toggle source
# File lib/bloc_record/schema.rb, line 9
def columns
  schema.keys
end
count() click to toggle source
# File lib/bloc_record/schema.rb, line 27
  def count
    connection.execute(<<-SQL)[0][0]
      SELECT COUNT(*) FROM #{table}
    SQL
  end
schema() click to toggle source
# File lib/bloc_record/schema.rb, line 17
def schema
  unless @schema
    @schema = {}
    connection.table_info(table) do |col|
      @schema[col["name"]] = col["type"]
    end
  end
  @schema
end
table() click to toggle source
# File lib/bloc_record/schema.rb, line 5
def table
  BlocRecord::Utility.underscore(name)
end