Class: ActiveScaffold::Tableless
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActiveScaffold::Tableless
show all
- Defined in:
- lib/active_scaffold/tableless.rb
Defined Under Namespace
Modules: Association, CollectionAssociation, RelationExtension, SingularAssociation
Classes: AssociationScope, Column, Connection, Relation, StatementCache
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.column(name, sql_type = nil, options = {}) ⇒ Object
178
179
180
181
|
# File 'lib/active_scaffold/tableless.rb', line 178
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
|
163
164
165
|
# File 'lib/active_scaffold/tableless.rb', line 163
def self.columns
@columns ||= []
end
|
.columns_hash ⇒ Object
151
152
153
154
155
156
157
|
# File 'lib/active_scaffold/tableless.rb', line 151
def self.columns_hash
if self < ActiveScaffold::Tableless
@columns_hash ||= Hash[columns.map { |c| [c.name, c] }]
else
super
end
end
|
.connection ⇒ Object
174
175
176
|
# File 'lib/active_scaffold/tableless.rb', line 174
def self.connection
@connection ||= Connection.new(self)
end
|
.execute_simple_calculation(relation, operation, column_name, distinct) ⇒ Object
191
192
193
194
195
196
197
|
# File 'lib/active_scaffold/tableless.rb', line 191
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) ⇒ Object
183
184
185
|
# File 'lib/active_scaffold/tableless.rb', line 183
def self.find_all(relation)
raise 'self.find_all must be implemented in a Tableless model'
end
|
.find_one(id, relation) ⇒ Object
187
188
189
|
# File 'lib/active_scaffold/tableless.rb', line 187
def self.find_one(id, relation)
raise 'self.find_one must be implemented in a Tableless model'
end
|
.initialize_find_by_cache ⇒ Object
158
159
160
|
# File 'lib/active_scaffold/tableless.rb', line 158
def self.initialize_find_by_cache
self.find_by_statement_cache = Hash.new { |h, k| h[k] = StatementCache.new(k) }
end
|
.table_exists? ⇒ Boolean
169
170
171
|
# File 'lib/active_scaffold/tableless.rb', line 169
def self.table_exists?
true
end
|
.table_name ⇒ Object
166
167
168
|
# File 'lib/active_scaffold/tableless.rb', line 166
def self.table_name
@table_name ||= ActiveModel::Naming.plural(self)
end
|
Instance Method Details
#_create_record ⇒ Object
Also known as:
create_record, create
203
204
205
|
# File 'lib/active_scaffold/tableless.rb', line 203
def _create_record run_callbacks(:create) {}
end
|
#_update_record ⇒ Object
Also known as:
update_record, update
209
210
211
|
# File 'lib/active_scaffold/tableless.rb', line 209
def _update_record(*) run_callbacks(:update) {}
end
|
199
200
201
|
# File 'lib/active_scaffold/tableless.rb', line 199
def destroy
raise 'destroy must be implemented in a Tableless model'
end
|