Module: Versioning::ClassMethods
- Defined in:
- app/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
- #published ⇒ Object
- #unpublished ⇒ Object
- #unpublished_or_follow_up ⇒ Object
- #unsynced ⇒ Object
Instance Method Details
#by_origin(origin) ⇒ Object
30 31 32 |
# File 'app/concerns/versioning.rb', line 30 def by_origin(origin) where(origin: origin) end |
#editor_selectable ⇒ Object
The following method returns all objects which should be selectable by the editor
43 44 45 46 47 48 49 |
# File 'app/concerns/versioning.rb', line 43 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
51 52 53 |
# File 'app/concerns/versioning.rb', line 51 def in_edit_mode where(arel_table[:locked_by].not_eq(nil)) end |
#include_to_deep_cloning(*association_names) ⇒ Object
67 68 69 70 71 72 |
# File 'app/concerns/versioning.rb', line 67 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
74 75 76 77 |
# File 'app/concerns/versioning.rb', line 74 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
34 35 36 |
# File 'app/concerns/versioning.rb', line 34 def published where(arel_table[:published_at].not_eq(nil)) end |
#unpublished ⇒ Object
38 39 40 |
# File 'app/concerns/versioning.rb', line 38 def unpublished where(published_at: nil) end |
#unpublished_or_follow_up ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/concerns/versioning.rb', line 55 def unpublished_or_follow_up where( arel_table[:published_at].eq(nil).or( arel_table[:follow_up].not_eq(nil) ) ) end |
#unsynced ⇒ Object
63 64 65 |
# File 'app/concerns/versioning.rb', line 63 def unsynced where(rdf_updated_at: nil) end |