Module: LooseLeaf::Document::ClassMethods

Defined in:
lib/loose_leaf/document.rb

Instance Method Summary collapse

Instance Method Details

#collaborative_attributes(*attributes) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/loose_leaf/document.rb', line 13

def collaborative_attributes(*attributes)
  return @collaborative_attributes if attributes.size.zero?

  @collaborative_attributes = attributes.map(&:to_s)

  bind_collaborative_document_attributes
end

#collaborative_key(attribute = nil) ⇒ Object



21
22
23
24
# File 'lib/loose_leaf/document.rb', line 21

def collaborative_key(attribute = nil)
  return @collaborative_key || :id if attribute.blank?
  @collaborative_key ||= attribute
end

#find_by_collaborative_key(key) ⇒ Object



26
27
28
29
30
# File 'lib/loose_leaf/document.rb', line 26

def find_by_collaborative_key(key)
  query = {}
  query[collaborative_key] = key
  find_by(query)
end