Module: Friendly::Document

Includes:
Associations, Attributes, Convenience, Scoping, Storage
Defined in:
lib/friendly/document.rb,
lib/friendly/document/mixin.rb,
lib/friendly/document/storage.rb,
lib/friendly/document/scoping.rb,
lib/friendly/document/attributes.rb,
lib/friendly/document/convenience.rb,
lib/friendly/document/associations.rb

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Attributes

#assign, #assign_default_values, #attribute_changed?, #attribute_was, #attributes=, #changed, #changed?, #initialize, #not_changed, #reset_changes, #save, #to_hash, #will_change

Methods included from Mixin

#included

Methods inherited from Storage

#all, #count, #create, #destroy, #first, #satisfies?, #update

Methods included from Convenience

#update_attributes

Class Attribute Details

+ (Object) documents



23
24
25
# File 'lib/friendly/document.rb', line 23

def documents
  @documents ||= []
end

Class Method Details

+ (Object) create_tables!



27
28
29
# File 'lib/friendly/document.rb', line 27

def create_tables!
  documents.each { |d| d.create_tables! }
end

+ (Object) included(klass)



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

def included(klass)
  documents << klass
  klass.class_eval do
    extend ClassMethods
    attribute :id,         UUID
    attribute :created_at, Time
    attribute :updated_at, Time
  end
end

Instance Method Details

- (Object) ==(comparison_object)



63
64
65
66
67
68
# File 'lib/friendly/document.rb', line 63

def ==(comparison_object)
  comparison_object.equal?(self) ||
    (comparison_object.is_a?(self.class) &&
      !comparison_object.new_record? && 
        comparison_object.id == id)
end

- (Object) new_record



54
55
56
57
# File 'lib/friendly/document.rb', line 54

def new_record
  @new_record = true if @new_record.nil?
  @new_record
end

- (Object) new_record=(value)



59
60
61
# File 'lib/friendly/document.rb', line 59

def new_record=(value)
  @new_record = value
end

- (Boolean) new_record?

Returns:



50
51
52
# File 'lib/friendly/document.rb', line 50

def new_record?
  new_record
end

- (Object) table_name



46
47
48
# File 'lib/friendly/document.rb', line 46

def table_name
  self.class.table_name
end