Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/citier/core_ext.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](column_name) ⇒ Object



3
4
5
# File 'lib/citier/core_ext.rb', line 3

def self.[](column_name) 
  arel_table[column_name]
end

.all(*args) ⇒ Object



11
12
13
14
# File 'lib/citier/core_ext.rb', line 11

def self.all(*args)
  # For some reason need to override this so it uses my modified find function which reloads each object to pull in all properties.
  return find(:all, *args)
end

.create_class_writable(class_reference) ⇒ Object

creation of a new class which inherits from ActiveRecord::Base



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/citier/core_ext.rb', line 16

def self.create_class_writable(class_reference)  #creation of a new class which inherits from ActiveRecord::Base
  Class.new(ActiveRecord::Base) do
    t_name = class_reference.table_name
    t_name = t_name[5..t_name.length]

    if t_name[0..5] == "view_"
      t_name = t_name[5..t_name.length]
    end

    # set the name of the table associated to this class
    # this class will be associated to the writable table of the class_reference class
    set_table_name(t_name)
  end
end

Instance Method Details

#is_new_record(state) ⇒ Object



7
8
9
# File 'lib/citier/core_ext.rb', line 7

def is_new_record(state)
  @new_record = state
end