Module: WithoutScope::ActsAsRevisable::Common::ClassMethods
- Defined in:
- lib/acts_as_revisable/acts/common.rb
Instance Method Summary collapse
-
#instantiate(record) ⇒ Object
acts_as_revisable’s override for instantiate so we can return the appropriate type of model based on whether or not the record is the current record.
-
#revisable_should_clone_column?(col) ⇒ Boolean
Returns true if the revision should clone the given column.
Instance Method Details
#instantiate(record) ⇒ Object
acts_as_revisable’s override for instantiate so we can return the appropriate type of model based on whether or not the record is the current record.
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/acts_as_revisable/acts/common.rb', line 179 def instantiate(record) #:nodoc: is_current = columns_hash["revisable_is_current"].type_cast( record["revisable_is_current"]) if (is_current && self == self.revisable_class) || (!is_current && self == self.revision_class) return super(record) end object = if is_current self.revisable_class else self.revision_class end.allocate object.instance_variable_set("@attributes", record) object.instance_variable_set("@attributes_cache", Hash.new) if object.respond_to_without_attributes?(:after_find) object.send(:callback, :after_find) end if object.respond_to_without_attributes?(:after_initialize) object.send(:callback, :after_initialize) end object end |
#revisable_should_clone_column?(col) ⇒ Boolean
Returns true if the revision should clone the given column.
171 172 173 174 |
# File 'lib/acts_as_revisable/acts/common.rb', line 171 def revisable_should_clone_column?(col) #:nodoc: return false if (REVISABLE_SYSTEM_COLUMNS + REVISABLE_UNREVISABLE_COLUMNS).member? col true end |