Class: ActiveRecord::Illusion
- Inherits:
-
Base
- Object
- Base
- ActiveRecord::Illusion
- Defined in:
- lib/active_illusion.rb
Overview
end
Class Method Summary collapse
- .column(name, sql_type = :string, default = nil, null = true) ⇒ Object
- .columns ⇒ Object
- .columns_hash ⇒ Object
- .default_scope_with_wrap ⇒ Object
- .find_all ⇒ Object
- .table_name ⇒ Object
- .view ⇒ Object
Instance Method Summary collapse
Class Method Details
.column(name, sql_type = :string, default = nil, null = true) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/active_illusion.rb', line 81 def self.column(name, sql_type = :string, default = nil, null = true) column = ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) columns << column columns_hash[name.to_s] = column end |
.columns ⇒ Object
54 55 56 |
# File 'lib/active_illusion.rb', line 54 def self.columns() @columns ||= [] end |
.columns_hash ⇒ Object
58 59 60 |
# File 'lib/active_illusion.rb', line 58 def self.columns_hash() @columns_hash ||= {} end |
.default_scope_with_wrap ⇒ Object
67 68 |
# File 'lib/active_illusion.rb', line 67 def default_scope_with_wrap end |
.find_all ⇒ Object
62 63 64 |
# File 'lib/active_illusion.rb', line 62 def self.find_all raise "please override" end |
.table_name ⇒ Object
90 91 92 |
# File 'lib/active_illusion.rb', line 90 def self.table_name to_s.underscore.pluralize end |
.view ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/active_illusion.rb', line 71 def self.view = class << self;self;end m = yield table = self.to_s.underscore.pluralize .send :define_method, :default_scope do q = m.arel.as table select{}.from(q) end end |
Instance Method Details
#readonly? ⇒ Boolean
94 95 96 |
# File 'lib/active_illusion.rb', line 94 def readonly? true end |