Module: Arke::Resource::Persistence

Extended by:
ActiveSupport::Concern
Defined in:
lib/arke/resource/persistence.rb

Defined Under Namespace

Modules: Callbacks, ClassMethods

Instance Method Summary collapse

Instance Method Details

#destroyObject



47
48
49
# File 'lib/arke/resource/persistence.rb', line 47

def destroy
  delete @_attributes
end

#persisted?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/arke/resource/persistence.rb', line 71

def persisted?
  !self.id.empty?
end

#reloadObject



66
67
68
69
# File 'lib/arke/resource/persistence.rb', line 66

def reload
  @_attributes = self.get(@_attributes.clone)
  self
end

#saveObject



51
52
53
54
55
56
57
58
# File 'lib/arke/resource/persistence.rb', line 51

def save
  unless self.persisted?
    return true if (@_attributes = post(@_attributes))
  else
    return update(@_attributes)
  end
  false
end

#update(attributes) ⇒ Object



60
61
62
63
64
# File 'lib/arke/resource/persistence.rb', line 60

def update(attributes)
  @_attributes = attributes
  return true if (@_attributes = put(@_attributes))
  false
end