Module: Exchanger::Persistence

Included in:
Element
Defined in:
lib/exchanger/persistence.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) destroy



15
16
17
18
19
20
21
# File 'lib/exchanger/persistence.rb', line 15

def destroy
  if new_record?
    false
  else
    delete
  end
end

- (Boolean) new_record?

Returns:



3
4
5
# File 'lib/exchanger/persistence.rb', line 3

def new_record?
  not id
end

- (Object) reload

Reloads the Element attributes from Exchanger.



24
25
26
27
28
29
30
31
32
33
# File 'lib/exchanger/persistence.rb', line 24

def reload
  if new_record?
    false
  else
    reloaded_element = self.class.find(self.id)
    @attributes = reloaded_element.attributes
    reset_modifications
    true
  end
end

- (Object) save



7
8
9
10
11
12
13
# File 'lib/exchanger/persistence.rb', line 7

def save
  if new_record?
    create
  else
    update
  end
end