class Tableless
Public Class Methods
column(name, sql_type = nil, options = {})
click to toggle source
# File lib/active_scaffold/tableless.rb, line 185 def self.column(name, sql_type = nil, options = {}) column = Column.new(name.to_s, options[:default], sql_type.to_s, options.key?(:null) ? options[:null] : true) column.tap { columns << column } end
columns()
click to toggle source
# File lib/active_scaffold/tableless.rb, line 170 def self.columns @tableless_columns ||= [] end
columns_hash()
click to toggle source
Calls superclass method
# File lib/active_scaffold/tableless.rb, line 158 def self.columns_hash if self < ActiveScaffold::Tableless @columns_hash ||= Hash[columns.map { |c| [c.name, c] }] else super end end
connection()
click to toggle source
# File lib/active_scaffold/tableless.rb, line 181 def self.connection @connection ||= Connection.new(self) end
execute_simple_calculation(relation, operation, column_name, distinct)
click to toggle source
# File lib/active_scaffold/tableless.rb, line 198 def self.execute_simple_calculation(relation, operation, column_name, distinct) if operation == 'count' && [relation.klass.primary_key, :all].include?(column_name) find_all(relation).size else raise "self.execute_simple_calculation must be implemented in a Tableless model to support #{operation} #{column_name}#{' distinct' if distinct} columns" end end
find_all(relation)
click to toggle source
# File lib/active_scaffold/tableless.rb, line 190 def self.find_all(relation) raise 'self.find_all must be implemented in a Tableless model' end
find_one(id, relation)
click to toggle source
# File lib/active_scaffold/tableless.rb, line 194 def self.find_one(id, relation) raise 'self.find_one must be implemented in a Tableless model' end
initialize_find_by_cache()
click to toggle source
# File lib/active_scaffold/tableless.rb, line 165 def self.initialize_find_by_cache self.find_by_statement_cache = Hash.new { |h, k| h[k] = StatementCache.new(k) } end
table_exists?()
click to toggle source
# File lib/active_scaffold/tableless.rb, line 176 def self.table_exists? true end
table_name()
click to toggle source
# File lib/active_scaffold/tableless.rb, line 173 def self.table_name @table_name ||= ActiveModel::Naming.plural(self) end
Private Class Methods
relation()
click to toggle source
# File lib/active_scaffold/tableless.rb, line 142 def relation ActiveScaffold::Tableless::Relation.new(self, arel_table) end
Public Instance Methods
destroy()
click to toggle source
# File lib/active_scaffold/tableless.rb, line 206 def destroy raise 'destroy must be implemented in a Tableless model' end