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.
- #in_edit_mode ⇒ Object
- #include_to_deep_cloning(*association_names) ⇒ Object
- #includes_to_deep_cloning ⇒ Object
- #locked ⇒ Object
- #published ⇒ Object
- #published_with_newer_versions ⇒ Object
- #unpublished ⇒ Object
- #unpublished_or_follow_up ⇒ Object
- #unsynced ⇒ Object
Instance Method Details
#by_origin(origin) ⇒ Object
32 33 34 |
# File 'app/models/concerns/versioning.rb', line 32 def by_origin(origin) where(origin: origin) end |
#editor_selectable ⇒ Object
The following method returns all objects which should be selectable by the editor
58 59 60 61 62 63 64 |
# File 'app/models/concerns/versioning.rb', line 58 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 |
#in_edit_mode ⇒ Object
66 67 68 |
# File 'app/models/concerns/versioning.rb', line 66 def in_edit_mode where(arel_table[:locked_by].not_eq(nil)) end |
#include_to_deep_cloning(*association_names) ⇒ Object
82 83 84 85 86 87 |
# File 'app/models/concerns/versioning.rb', line 82 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
89 90 91 92 |
# File 'app/models/concerns/versioning.rb', line 89 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 |
#locked ⇒ Object
44 45 46 |
# File 'app/models/concerns/versioning.rb', line 44 def locked where(arel_table[:locked_by].not_eq(nil)) end |
#published ⇒ Object
36 37 38 |
# File 'app/models/concerns/versioning.rb', line 36 def published where(arel_table[:published_at].not_eq(nil)) end |
#published_with_newer_versions ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'app/models/concerns/versioning.rb', line 48 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
40 41 42 |
# File 'app/models/concerns/versioning.rb', line 40 def unpublished where(published_at: nil) end |
#unpublished_or_follow_up ⇒ Object
70 71 72 73 74 75 76 |
# File 'app/models/concerns/versioning.rb', line 70 def unpublished_or_follow_up where( arel_table[:published_at].eq(nil).or( arel_table[:follow_up].not_eq(nil) ) ) end |
#unsynced ⇒ Object
78 79 80 |
# File 'app/models/concerns/versioning.rb', line 78 def unsynced where(rdf_updated_at: nil) end |