Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/citier4/core_ext.rb
Class Method Summary collapse
- .[](column_name) ⇒ Object
- .acts_as_citier? ⇒ Boolean
-
.create_class_root_writable(class_reference) ⇒ Object
create the writeable class which inherits from ActiveRecord::Base for the root class (TODO merge the code with the cild).
-
.create_class_writable(class_reference) ⇒ Object
create the writeable class which inherits from ActiveRecord::Base.
- .set_acts_as_citier(citier) ⇒ Object
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
9 10 11 |
# File 'lib/citier4/core_ext.rb', line 9 def self.acts_as_citier? @acts_as_citier || false end |
.create_class_root_writable(class_reference) ⇒ Object
create the writeable class which inherits from ActiveRecord::Base for the root class (TODO merge the code with the cild)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/citier4/core_ext.rb', line 24 def self.create_class_root_writable(class_reference) Class.new(ActiveRecord::Base) do # include Citier4::InstanceMethods::ForcedWriters include Citier4::RootInstanceMethods # 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] self.table_name = class_reference.table_name # remove the STI mecanizm self.inheritance_column = :_type_disabled def changes_applied super end def clear_attribute_changes(att) super end def clear_changes_information super end end end |
.create_class_writable(class_reference) ⇒ Object
create the writeable class which inherits from ActiveRecord::Base
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/citier4/core_ext.rb', line 51 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] def changes_applied super end def clear_attribute_changes(att) super end def clear_changes_information super end 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 |