Class: ActiveRecord::Illusion

Inherits:
Base
  • Object
show all
Defined in:
lib/active_illusion.rb

Overview

end

Class Method Summary collapse

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

.columnsObject



54
55
56
# File 'lib/active_illusion.rb', line 54

def self.columns() 
  @columns ||= [] 
end

.columns_hashObject



58
59
60
# File 'lib/active_illusion.rb', line 58

def self.columns_hash()
  @columns_hash ||= {}
end

.default_scope_with_wrapObject



67
68
# File 'lib/active_illusion.rb', line 67

def default_scope_with_wrap
end

.find_allObject



62
63
64
# File 'lib/active_illusion.rb', line 62

def self.find_all
  raise "please override"
end

.table_nameObject



90
91
92
# File 'lib/active_illusion.rb', line 90

def self.table_name
  to_s.underscore.pluralize
end

.viewObject



71
72
73
74
75
76
77
78
79
# File 'lib/active_illusion.rb', line 71

def self.view
  meta = class << self;self;end
  m = yield
  table = self.to_s.underscore.pluralize
  meta.send :define_method, :default_scope do
    q = m.arel.as table
    select{}.from(q)
  end
end

Instance Method Details

#readonly?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/active_illusion.rb', line 94

def readonly?
  true
end