Class: ActiveRecord::Base

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](column_name) ⇒ Object



13
14
15
# File 'lib/citier4/core_ext.rb', line 13

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

.acts_as_citier? ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/citier4/core_ext.rb', line 9

def self.acts_as_citier?
  @acts_as_citier || false
end

.create_class_writable(class_reference) ⇒ Object

create the writeable class which inherits from ActiveRecord::Base



22
23
24
25
26
27
28
29
30
31
# File 'lib/citier4/core_ext.rb', line 22

def self.create_class_writable(class_reference) 
  Class.new(ActiveRecord::Base) do
    include Citier4::InstanceMethods::ForcedWriters
    
    view_name = class_reference.table_name
    # set the name of the table associated to this class
    # this class will be associated to the writable table of the class_reference class
    self.table_name = view_name[5..view_name.length]
  end
end

.set_acts_as_citier(citier) ⇒ Object



5
6
7
# File 'lib/citier4/core_ext.rb', line 5

def self.set_acts_as_citier(citier)
  @acts_as_citier = citier
end

Instance Method Details

#is_new_record(state) ⇒ Object



17
18
19
# File 'lib/citier4/core_ext.rb', line 17

def is_new_record(state)
  @new_record = state
end