Module: Iqvoc::Versioning::ClassMethods

Defined in:
lib/iqvoc/versioning.rb

Instance Method Summary collapse

Instance Method Details

#by_origin(origin) ⇒ Object

********* Scopes



33
34
35
# File 'lib/iqvoc/versioning.rb', line 33

def by_origin(origin)
  where(:origin => origin)
end

#editor_selectableObject

The following method returns all objects which should be selectable by the editor



46
47
48
49
50
51
52
# File 'lib/iqvoc/versioning.rb', line 46

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_modeObject



54
55
56
# File 'lib/iqvoc/versioning.rb', line 54

def in_edit_mode
  where(arel_table[:locked_by].not_eq(nil))
end

#include_to_deep_cloning(*association_names) ⇒ Object



70
71
72
73
74
75
# File 'lib/iqvoc/versioning.rb', line 70

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_cloningObject



77
78
79
80
# File 'lib/iqvoc/versioning.rb', line 77

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

#publishedObject



37
38
39
# File 'lib/iqvoc/versioning.rb', line 37

def published
  where(arel_table[:published_at].not_eq(nil))
end

#unpublishedObject



41
42
43
# File 'lib/iqvoc/versioning.rb', line 41

def unpublished
  where(:published_at => nil)
end

#unpublished_or_follow_upObject



58
59
60
61
62
63
64
# File 'lib/iqvoc/versioning.rb', line 58

def unpublished_or_follow_up
  where(
    arel_table[:published_at].eq(nil).or(
      arel_table[:follow_up].not_eq(nil)
    )
  )
end

#unsyncedObject



66
67
68
# File 'lib/iqvoc/versioning.rb', line 66

def unsynced
  where(:rdf_updated_at => nil)
end