module LooseLeaf::Document
Public Instance Methods
apply_operation(data)
click to toggle source
# File lib/loose_leaf/document.rb, line 66 def apply_operation(data) operation = OT::TextOperation.from_a data[:operation] attribute = data[:attribute] version = data[:version] collaborative_attribute(attribute).apply_operation(operation, version) end
clear_collaborative_cache(attribute)
click to toggle source
# File lib/loose_leaf/document.rb, line 87 def clear_collaborative_cache(attribute) collaborative_attribute(attribute).clear_cache end
collaborative_attribute(attribute_name)
click to toggle source
# File lib/loose_leaf/document.rb, line 58 def collaborative_attribute(attribute_name) @collaborative_attributes[attribute_name.to_s] end
collaborative_id()
click to toggle source
# File lib/loose_leaf/document.rb, line 62 def collaborative_id @collaborative_id ||= send(self.class.collaborative_key) end
commit_collaborative_attributes(*attributes)
click to toggle source
# File lib/loose_leaf/document.rb, line 74 def commit_collaborative_attributes(*attributes) attributes = attributes.flatten.map(&:to_s) # Intersect with allowed attributes attributes &= self.class.collaborative_attributes attributes.each do |attribute| send("#{attribute}=", send("collaborative_#{attribute}")) end save end
setup_collaborative_attributes()
click to toggle source
# File lib/loose_leaf/document.rb, line 91 def setup_collaborative_attributes @collaborative_attributes = {} self.class.collaborative_attributes.each do |attribute| @collaborative_attributes[attribute] = DocumentAttribute.new(self, attribute) end end