Module: WithoutScope::ActsAsRevisable::Revisable::ClassMethods
- Defined in:
- lib/acts_as_revisable/acts/revisable.rb
Instance Method Summary collapse
-
#find(*args) ⇒ Object
acts_as_revisable’s override for find that allows for including revisions in the find.
-
#revisable_class ⇒ Object
Returns the revisable_class which in this case is simply
self
. -
#revisable_watch_columns ⇒ Object
Returns an Array of the columns that are watched for changes.
-
#revision_class ⇒ Object
Returns the actual
Revision
class based on the #revision_class_name. -
#revision_class_name ⇒ Object
Returns the
revision_class_name
as configured inacts_as_revisable
. -
#revisions_association_name ⇒ Object
Returns the name of the association acts_as_revisable creates.
-
#with_scope(*args, &block) ⇒ Object
acts_as_revisable’s override for with_scope that allows for including revisions in the scope.
Instance Method Details
#find(*args) ⇒ Object
acts_as_revisable’s override for find that allows for including revisions in the find.
Example
find(:all, :with_revisions => true)
434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 434 def find(*args) #:nodoc: = args.grep(Hash).first if && .delete(:with_revisions) with_exclusive_scope do super(*args) end else super(*args) end end |
#revisable_class ⇒ Object
Returns the revisable_class which in this case is simply self
.
459 460 461 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 459 def revisable_class #:nodoc: self end |
#revisable_watch_columns ⇒ Object
Returns an Array of the columns that are watched for changes.
470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 470 def revisable_watch_columns #:nodoc: return self.revisable_columns unless self.revisable_columns.blank? return self.revisable_columns ||= [] if self..except == :all return self.revisable_columns ||= [self..only].flatten.map(&:to_s).map(&:downcase) unless self..only.blank? except = [self..except].flatten || [] except += REVISABLE_SYSTEM_COLUMNS except += REVISABLE_UNREVISABLE_COLUMNS except.uniq! self.revisable_columns ||= (column_names - except.map(&:to_s)).flatten.map(&:downcase) end |
#revision_class ⇒ Object
Returns the actual Revision
class based on the #revision_class_name.
454 455 456 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 454 def revision_class #:nodoc: self.revisable_revision_class ||= self.revision_class_name.constantize end |
#revision_class_name ⇒ Object
Returns the revision_class_name
as configured in acts_as_revisable
.
448 449 450 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 448 def revision_class_name #:nodoc: self..revision_class_name || "#{self.name}Revision" end |
#revisions_association_name ⇒ Object
Returns the name of the association acts_as_revisable creates.
465 466 467 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 465 def revisions_association_name #:nodoc: revision_class_name.pluralize.underscore end |
#with_scope(*args, &block) ⇒ Object
acts_as_revisable’s override for with_scope that allows for including revisions in the scope.
Example
with_scope(:with_revisions => true) do
...
end
416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 416 def with_scope(*args, &block) #:nodoc: = (args.grep(Hash).first || {})[:find] if && .delete(:with_revisions) with_exclusive_scope do super(*args, &block) end else super(*args, &block) end end |