Module: Versioning::ClassMethods
- Defined in:
- app/models/concerns/versioning.rb
Instance Method Summary collapse
- #by_origin(origin) ⇒ Object
-
#editor_selectable ⇒ Object
The following method returns all objects which should be selectable by the editor.
- #include_to_deep_cloning(*association_names) ⇒ Object
- #includes_to_deep_cloning ⇒ Object
- #published ⇒ Object
- #published_with_newer_versions ⇒ Object
- #unpublished ⇒ Object
- #unpublished_or_follow_up ⇒ Object
- #unsynced ⇒ Object
Instance Method Details
#by_origin(origin) ⇒ Object
34 35 36 |
# File 'app/models/concerns/versioning.rb', line 34 def by_origin(origin) default_scoped.where(origin: origin) end |
#editor_selectable ⇒ Object
The following method returns all objects which should be selectable by the editor
56 57 58 59 60 61 62 |
# File 'app/models/concerns/versioning.rb', line 56 def editor_selectable where( arel_table[:published_at].not_eq(nil).or( # == published (is there a way to OR combine two scopes? `published OR where(...)`) arel_table[:published_at].eq(nil).and(arel_table[:published_version_id].eq(nil)) # this are all unpublished with no published version ) ) end |
#include_to_deep_cloning(*association_names) ⇒ Object
76 77 78 79 80 81 |
# File 'app/models/concerns/versioning.rb', line 76 def include_to_deep_cloning(*association_names) (@@include_to_deep_cloning ||= {})[self] ||= [] association_names.each do |association_name| @@include_to_deep_cloning[self] << association_name end end |
#includes_to_deep_cloning ⇒ Object
83 84 85 86 |
# File 'app/models/concerns/versioning.rb', line 83 def includes_to_deep_cloning (@@include_to_deep_cloning ||= {})[self] ||= [] (@@include_to_deep_cloning.keys & self.ancestors).map{|c| @@include_to_deep_cloning[c]}.flatten.compact end |
#published ⇒ Object
38 39 40 |
# File 'app/models/concerns/versioning.rb', line 38 def published where.not(published_at: nil) end |
#published_with_newer_versions ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/models/concerns/versioning.rb', line 46 def published_with_newer_versions # published objects without objects which have a new one in editing published_objects = arel_table[:published_at].not_eq(nil).and(arel_table[:origin].not_in(unpublished.map(&:origin))) # only unpublished objects unpublished_objects = arel_table[:published_at].eq(nil) where(published_objects.or(unpublished_objects)) end |
#unpublished ⇒ Object
42 43 44 |
# File 'app/models/concerns/versioning.rb', line 42 def unpublished where(published_at: nil) end |
#unpublished_or_follow_up ⇒ Object
64 65 66 67 68 69 70 |
# File 'app/models/concerns/versioning.rb', line 64 def unpublished_or_follow_up where( arel_table[:published_at].eq(nil).or( arel_table[:follow_up].not_eq(nil) ) ) end |
#unsynced ⇒ Object
72 73 74 |
# File 'app/models/concerns/versioning.rb', line 72 def unsynced where(rdf_updated_at: nil) end |