Module: FatJam::ActsAsRevisable::Revision::ClassMethods
- Defined in:
- lib/acts_as_revisable/acts/revision.rb
Instance Method Summary collapse
-
#revisable_association_name ⇒ Object
Returns the name of the association acts_as_revision creates.
-
#revisable_class ⇒ Object
Returns the actual
Revisable
class based on the #revisable_class_name. -
#revisable_class_name ⇒ Object
Returns the
revisable_class_name
as configured inacts_as_revisable
. -
#revision_class ⇒ Object
Returns the revision_class which in this case is simply
self
. -
#revision_class_name ⇒ Object
:nodoc:.
-
#revision_cloned_associations ⇒ Object
Returns an array of the associations that should be cloned.
Instance Method Details
#revisable_association_name ⇒ Object
Returns the name of the association acts_as_revision creates.
128 129 130 |
# File 'lib/acts_as_revisable/acts/revision.rb', line 128 def revisable_association_name #:nodoc: revisable_class_name.downcase end |
#revisable_class ⇒ Object
Returns the actual Revisable
class based on the #revisable_class_name.
113 114 115 |
# File 'lib/acts_as_revisable/acts/revision.rb', line 113 def revisable_class #:nodoc: self.revisable_revisable_class ||= revisable_class_name.constantize end |
#revisable_class_name ⇒ Object
Returns the revisable_class_name
as configured in acts_as_revisable
.
107 108 109 |
# File 'lib/acts_as_revisable/acts/revision.rb', line 107 def revisable_class_name #:nodoc: self..revisable_class_name || self.class_name.gsub(/Revision/, '') end |
#revision_class ⇒ Object
Returns the revision_class which in this case is simply self
.
118 119 120 |
# File 'lib/acts_as_revisable/acts/revision.rb', line 118 def revision_class #:nodoc: self end |
#revision_class_name ⇒ Object
:nodoc:
122 123 124 |
# File 'lib/acts_as_revisable/acts/revision.rb', line 122 def revision_class_name #:nodoc: self.name end |
#revision_cloned_associations ⇒ Object
Returns an array of the associations that should be cloned.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/acts_as_revisable/acts/revision.rb', line 133 def revision_cloned_associations #:nodoc: clone_associations = self..clone_associations self.revisable_cloned_associations ||= if clone_associations.blank? [] elsif clone_associations.eql? :all revisable_class.reflect_on_all_associations.map(&:name) elsif clone_associations.is_a? [].class clone_associations elsif clone_associations[:only] [clone_associations[:only]].flatten elsif clone_associations[:except] revisable_class.reflect_on_all_associations.map(&:name) - [clone_associations[:except]].flatten end end |