Module: FatJam::ActsAsRevisable::Revisable::ClassMethods
- Defined in:
- lib/acts_as_revisable/acts/revisable.rb
Instance Method Summary collapse
-
#find_with_revisable(*args) ⇒ Object
acts_as_revisable’s override for find that allows for including revisions in the find.
-
#find_with_revisions(*args) ⇒ Object
Equivalent to: find(…, :with_revisions => true).
-
#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_with_revisable(*args, &block) ⇒ Object
acts_as_revisable’s override for with_scope that allows for including revisions in the scope.
Instance Method Details
#find_with_revisable(*args) ⇒ Object
acts_as_revisable’s override for find that allows for including revisions in the find.
Example
find(:all, :with_revisions => true)
424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 424 def find_with_revisable(*args) #:nodoc: = args.grep(Hash).first if && .delete(:with_revisions) without_model_scope do find_without_revisable(*args) end else find_without_revisable(*args) end end |
#find_with_revisions(*args) ⇒ Object
Equivalent to:
find(..., :with_revisions => true)
438 439 440 441 442 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 438 def find_with_revisions(*args) args << {} if args.grep(Hash).blank? args.grep(Hash).first.update({:with_revisions => true}) find_with_revisable(*args) end |
#revisable_class ⇒ Object
Returns the revisable_class which in this case is simply self
.
457 458 459 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 457 def revisable_class #:nodoc: self end |
#revisable_watch_columns ⇒ Object
Returns an Array of the columns that are watched for changes.
468 469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 468 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.
452 453 454 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 452 def revision_class #:nodoc: self.revisable_revision_class ||= revision_class_name.constantize end |
#revision_class_name ⇒ Object
Returns the revision_class_name
as configured in acts_as_revisable
.
446 447 448 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 446 def revision_class_name #:nodoc: self..revision_class_name || "#{self.class_name}Revision" end |
#revisions_association_name ⇒ Object
Returns the name of the association acts_as_revisable creates.
463 464 465 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 463 def revisions_association_name #:nodoc: revision_class_name.pluralize.downcase end |
#with_scope_with_revisable(*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
406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/acts_as_revisable/acts/revisable.rb', line 406 def with_scope_with_revisable(*args, &block) #:nodoc: = (args.grep(Hash).first || {})[:find] if && .delete(:with_revisions) without_model_scope do with_scope_without_revisable(*args, &block) end else with_scope_without_revisable(*args, &block) end end |